What the JSON formatter does
The tool reads your text with its own strict JSON parser. Valid input is rewritten with the indentation you pick (2 spaces, 4 spaces or a tab) or minified onto a single line, and object keys can optionally be sorted at every level. Invalid input produces the line and column of the first error plus the offending line with a caret (^) under the exact character.
It is built for developers reading API responses, anyone hunting a stray comma in a config file, and SEO work on structured data. Once the syntax is clean, check Schema.org markup itself with the JSON-LD validator.
How to use
- Paste JSON into the input or open a
.jsonfile of up to 5 MiB. - Input up to 256 KiB is validated as you type with a 150 ms delay; larger input is processed only when you press “Format”, so the page stays responsive.
- Choose the output style: 2 spaces, 4 spaces, tab or minified, and tick the box to sort keys.
- If there is an error, read the line:column message and look at the caret, fix the text and the result refreshes.
- Copy the result or download it as
formatted.json/minified.json. The share link includes your input only if you tick the box and the text is short.
Validation rules (RFC 8259)
The parser is deliberately unforgiving: JSON5, JavaScript object literals and commented config formats are not accepted, and each is rejected with a specific message. Only space, tab, line feed and carriage return count as whitespace. Strings cannot contain unescaped control characters such as a raw line break; valid escapes after a backslash are ", \, /, b, f, n, r, t and u followed by four hex digits.
| Input | Result |
|---|---|
{"a": 1,} | Trailing comma error; the caret points at the comma |
{a: 1} or {'a': 1} | Unquoted key or single-quote error |
// note or /* note */ | JSON has no comments |
NaN, Infinity, -Infinity | Not valid JSON numbers |
012, 1., .5, +1, 0x1F | Invalid number format |
{} {} | Extra content after the value |
Columns are counted in code points, so an emoji or a Turkish letter such as ş is one column. CRLF, LF and CR each count as a single line break. A UTF-8 byte order mark at the start is ignored, as RFC 8259 permits, and reported as a warning.
Big numbers and duplicate keys
JSON.parse in browsers turns numbers into 64-bit floating-point values, so integers above 2^53 such as 9007199254740993 and decimals with more than 17 significant digits are rounded without notice. This tool never converts numbers: it copies each one to the output exactly as written and tells you how many would lose precision in a typical parser. Strings, including their escape sequences, are preserved as written too.
RFC 8259 says object keys should be unique but does not require it, so text with a duplicate key is still syntactically valid. Libraries disagree on whether the first or last value wins, so the tool lists each duplicate with its position and the line where the key first appeared, and keeps both members when formatting.
Example and interpretation
The Example button loads this minified input:
{"product":"Tea glass","price":149.90,"inStock":true,"tags":["kitchen","glass"],"orderId":90071992547409931,"price":129.90}The text is a valid object, and with 2-space indentation every member goes on its own line. Because price appears twice you get a duplicate key warning with its line and column. JavaScript would round orderId and JSON.stringify would write it back as 90071992547409940; the tool writes 90071992547409931 unchanged and adds a precision warning. 149.90 also stays 149.90 rather than becoming 149.9. Add a comma before the closing brace and the verdict switches to invalid, with the caret on that comma.
Limits and privacy
- Up to 5 MiB of input and 256 nested object/array levels; beyond that you get a clear error, never silent truncation.
- Only the first syntax error is reported; the next one appears once you fix it.
- It does not validate against a JSON Schema and does not check what fields mean or whether they are required.
- There is no tree view; the output is plain text.
- Input, files and output are processed only in your browser, never uploaded or stored. Do not put API keys or personal data into a share link: anyone with the link can read it.
Frequently asked questions
Why do comments or trailing commas cause an error?
Standard JSON (RFC 8259) allows neither. JSON5 and some config formats accept them, but APIs and most parsers reject them, so the tool reports them as errors.
Will my large numbers change?
No. Numbers are copied to the output exactly as written, so 0.10 or a 20-digit ID is not rounded. You get a warning when another parser might lose precision.
Does sorting keys change my data?
Values stay the same; only the order of object members changes. Keys are sorted by UTF-16 code unit, duplicates keep their relative order, and arrays are never reordered.
Is my JSON sent to a server?
No. Parsing and formatting run entirely in your browser and no network request is made. Your text is only placed in a link if you choose to include the input when sharing.
How do I read JSON that is Base64-encoded?
Decode it first with the Base64 encoder and decoder, then paste the resulting JSON here. URL-safe Base64 used in JWTs can be decoded there as well.