What JSON is, and why the syntax is so strict
JSON (JavaScript Object Notation) is a text format for exchanging data, defined by the standards ECMA-404 and IETF RFC 8259. Despite the name it is not tied to JavaScript: Python, Java, Go, PHP and nearly every other language read and write it the same way, which is why it became the default for web APIs and configuration files. The grammar is small and unforgiving on purpose. Two different systems must read the same text as the same data, so there is no room for "close enough". The price is that one stray comma or quote makes the whole document invalid. This tool translates that rejection into a position you can find and a list of the usual causes. Your input is parsed by the browser's ownJSON.parse on your device, and the script on this page contains no network request, so nothing you paste is uploaded or stored.
The six kinds of value
| Kind | Example | What to watch |
|---|---|---|
| String | "hello", "a\nb" | Double quotes only. Control characters such as a line break must be escaped as \n or \t. |
| Number | 30, -1.5, 2e3 | No leading zeros (08), hex (0xFF), NaN, Infinity or a trailing dot such as 1. |
| Boolean | true, false | Lowercase only; True and FALSE are errors. |
| null | null | undefined does not exist in JSON. |
| Array | [1, "a", null] | No comma after the last element. |
| Object | a set of key: value pairs | Keys must be double-quoted strings. No comma after the last pair. |
JSON has no date type, so dates travel as ISO 8601 strings such as 2025-01-01T00:00:00Z or as numeric timestamps. It cannot hold raw binary data either; binary is usually turned into text withBase64 first. For exchange between systems, RFC 8259 asks for UTF-8 text.
The eight syntax errors you will see most
These cover most of what goes wrong in practice. When parsing fails, the tool scans your input (ignoring the contents of strings) and lists any of the patterns below that it finds as "possible causes". It is a heuristic, not a diagnosis: more than one cause can be listed, and none may be listed if the problem is something unusual.
| Cause | What it looks like | Fix |
|---|---|---|
| Trailing comma | [1,2,] or a comma after the last pair | Delete the last comma |
| Single quotes | 'name' | Replace with double quotes |
| Unquoted key | name: 1 | Wrap the key in double quotes |
| Comments | // note, /* note */ | Remove them; JSON has no comments |
| Python or JS values | None, True, undefined, NaN | Use null, true, false, or drop the key |
| Missing comma | "a":1 "b":2 | Add a comma between the two pairs |
| Unbalanced brackets | The opening and closing brackets differ in type or number | Follow the indentation to the point where the pairing breaks |
| Line break inside a string | A real Enter keypress between double quotes | Escape it as <code>\n</code> |
How the error position is worked out
Browsers report a JSON error either as a character index ("at position 57", counted from zero) or, in newer engines, as a line and column. If only an index is given, the tool counts the line breaks before it to get the line number, measures from the last line break to get the column, and shows that line with a caret under the spot. The important caveat: the parser reports where it first noticed the problem, which is not always where you made the mistake.If a comma is missing between two pairs, the error points at the first character of the next pair, not at the gap. Always look at the text just before the caret as well. Wording and position format differ between browsers; when no location is available you still get the original message and the list of likely causes.
Pretty-print versus minify
The two forms mean exactly the same thing and differ only in whitespace. Use the indented form for reading and editing configuration or logs, and the one-line form for request bodies, URLs, environment variables and cookies. The sizes below were measured when this page was built, by encoding the same small object in each form (UTF-8 bytes).
{
"name": "Jane Doe",
"age": 30,
"tags": [
"a",
"b"
],
"address": {
"city": "Chicago"
}
}| Form | Size (bytes) |
|---|---|
| Minified (one line) | 74 |
| 2-space indent | 113 |
| 4-space indent | 137 |
| Tab indent | 101 |
The minified form of this example is about 35% smaller than the 2-space version. The gap grows with deeper nesting, but if the server compresses responses with gzip or Brotli, the difference on the wire is much smaller. A tab is smaller than spaces simply because each indentation level costs one byte instead of two or four.
Three checked examples where conversion changes a value
JSON goes text to value to text, so reformatting alone can change content. Every result below was produced by running the code while this page was built.
Example 1: a large integer loses precision
Parsing and printing {"id":12345678901234567890} returns the id as 12345678901234567000. JavaScript numbers are 64-bit floating point, so integers are exact only up to 9007199254740991, which is 2^53 minus 1. Identifiers longer than about 15 or 16 digits, such as social media post IDs or order numbers, are best exchanged as strings. When the tool sees an integer outside the safe range in your input, it shows a warning.
Example 2: key order, duplicate keys and number spelling
{"b":1,"2":2,"1":3} becomes {"1":3,"2":2,"b":1}. JavaScript lists integer-like keys such as "1" and "2" first, in ascending order, so the original order is not kept in this case. With {"a":1,"a":2}, RFC 8259 says names SHOULD be unique and leaves the behavior of duplicates open; the browser keeps the last value and gives {"a":2}. Numbers are normalized too: [0.1,1e3,1.0,-0] prints as [0.1,1000,1,0], with 1e3 becoming 1000, 1.0 becoming 1 and negative zero becoming 0. The meaning is unchanged, but if you need the exact characters preserved for a signature or a hash, do not use the reformatted output.
Example 3: comparing two documents with sorted keys
When two systems export the same data with keys in a different order, a visual comparison is painful. Convert each document with "Sort keys alphabetically" and pretty-print, then paste both into theText Diff Checker. Only real differences remain. Arrays keep their order because order carries meaning there; only object keys are sorted, at every level.
Limits, and when not to use this tool
- Only standard JSON is accepted. JSON5 and JSONC, the dialects that allow comments and trailing commas (many editor settings files use them), will be reported as errors; remove the comments first.
- JSON Lines or NDJSON logs, with one document per line, fail when pasted whole. Validate one line at a time.
- Files of tens of megabytes can make the browser tab unresponsive. For big data, use a command-line tool or an editor.
- Validation checks syntax only. Whether required keys exist or values have the right type is a job for a schema language such as JSON Schema.
- Nothing is sent to a server, but it is still wise not to paste passwords, tokens or personal data on a shared computer or while screen-sharing.
Where it fits in a workflow
- An API call fails with a 400 error: validate the request body first to rule out syntax, then look at the fields the server expects.
- You just edited a config file: run "Validate only" before saving so the application is not left unable to start.
- Minified output from a log is unreadable: pretty-print it, then use the Regex Tester to pull out patterns.
- A query string or form value contains JSON: decode it with the URL Encoder first, then paste the result here.
Frequently Asked Questions
Is the JSON I paste sent to a server?
No. Parsing and conversion run in your browser with JavaScript, and the page's script makes no network requests. Nothing you enter is sent or stored.
Does it accept JavaScript object literals with unquoted keys or single quotes?
No. Only standard JSON is accepted; keys and strings need double quotes. If you copied an object from a console, quote the keys and values first. The tool will flag quote problems among the possible causes.
The key order changed after formatting. Why?
If "Sort keys alphabetically" is on, that is intended. If it is off, the cause is usually integer-like keys such as "1" and "2", which JavaScript always lists first in ascending order (Example 2). JSON objects are unordered by definition, so the data means the same.
The last digits of a number turned into zeros.
JavaScript cannot represent integers beyond about 15 to 16 digits exactly. Do not rely on this tool's output for such values; the real fix is to have the source system send them as strings.
Is a bare number or string a valid JSON document?
Under RFC 8259, yes: 42 and "hello" are valid JSON texts. Older systems sometimes assume the top level is an object or array, so check what the receiving side expects.