Skip to content
dz / json-validator-line-numbers

JSON validator with line numbers

Paste your JSON – each problem is listed with its line and column and marked in the editor. Click one to jump there.

/json
Paste or type JSON – it is checked as you type.

Everything runs in your browser – the JSON is never sent anywhere. Numbers are kept exactly as written, even beyond JavaScript's precision.

The usual suspects

The example above contains two of the most common mistakes. Strict JSON (RFC 8259) does not allow:

  • Trailing commas – ["a", "b",]

  • Single quotes – keys and strings need double quotes: "debug"

  • Comments – neither // nor /* */

  • Unquoted keys, NaN, Infinity, undefined and hexadecimal numbers

  • Raw line breaks or tabs inside strings – write \n and \t

Config files such as tsconfig.json or VS Code settings are JSONC, which allows comments and trailing commas. Switch on the JSONC option to validate them without false alarms.

Validating in a terminal

jq . file.json                      # prints the error with line and column
python -m json.tool file.json
node -e "JSON.parse(require('fs').readFileSync('file.json','utf8'))"

Questions

Why does the error point to the line after the mistake?

A parser only notices a missing comma or bracket when the next token arrives. If the reported spot looks fine, check the end of the previous line.

Is my JSON sent anywhere?

No. Parsing, validation and formatting run entirely in your browser.

Can it fix the JSON for me?

Once the errors are fixed, Format pretty-prints and Minify compacts it. Big numbers and the exact text of strings are kept as written.

▸ About this tool

About the JSON Formatter & Validator

Introduction

JSON (JavaScript Object Notation) is the most common format for exchanging data between programs: REST and GraphQL APIs, configuration files, logs, NoSQL databases and message queues all speak it. Machines are happy with a single long line of JSON, but people are not. This tool turns any JSON into a readable, consistently indented document, squeezes it back into one line when you need to ship it, and tells you exactly where and why a document is invalid.

How to use it

  1. Paste, type or open your JSON. You can also drop a .json file anywhere on the page or use Open. The document is validated live as you type.

  2. Format (Ctrl + Enter) pretty-prints it with 2 spaces, 4 spaces or tabs. Minify removes every unnecessary space and line break.

  3. Tick Sort keys to order object keys alphabetically – handy before comparing two documents in a diff tool.

  4. Copy the result, save it as a file, or undo with Ctrl + Z.

Short links: develzone.org/json opens the formatter, develzone.org/minify minifies whatever you hand over to it. Pasting JSON into the search box on the home page brings you here too.

Errors explained in plain words

Instead of a generic "Unexpected token", the validator shows the line and column of every problem, underlines it in the editor and explains the usual cause:

  • Trailing comma – [1, 2, 3,] is fine in JavaScript, but not in JSON.

  • Single quotes – strings and keys must use double quotes: "name", not 'name'.

  • Unquoted keys – {name: "x"} is a JavaScript object literal; JSON needs {"name": "x"}.

  • Comments – standard JSON has none. Tick Allow comments & trailing commas for JSONC files such as tsconfig.json or VS Code settings; the output is always strict JSON.

  • Values JSON does not know – undefined, NaN, Infinity or Python's True / None.

  • Raw line breaks or tabs inside strings – they have to be escaped as \n and \t.

  • Duplicate keys are technically allowed, but most parsers silently keep only the last value, so they are reported as warnings.

Your numbers stay exactly as they are

Many online formatters run JSON.parse followed by JSON.stringify. That quietly changes data: JavaScript numbers have about 15–17 significant digits, so a 64-bit ID like 12345678901234567890 becomes 12345678901234567000, and 1.10 turns into 1.1. This formatter works on the syntax tree of your original text and copies every number and string character for character – only whitespace and (optionally) key order change.

Privacy

Formatting and validation run entirely in your browser. The JSON is never uploaded, logged or stored, so API responses with tokens or personal data are safe to paste. It also keeps working offline once the page has loaded.

A bit of history

JSON was specified by Douglas Crockford in the early 2000s as a subset of JavaScript object literals. It was standardised as ECMA-404 (2013) and RFC 8259 (2017), which also requires JSON exchanged between systems to be encoded as UTF-8. Its tiny grammar – objects, arrays, strings, numbers, true, false and null – is the reason it replaced XML as the default format of web APIs.

Interesting facts

  • The whole JSON grammar fits on a business card; Crockford famously printed it on the back of his.

  • JSON has no date type. Dates are usually ISO 8601 strings ("2024-11-09T11:00:00Z") or Unix timestamps – our Unix timestamp converter translates between the two.

  • Coming from XML? The XML to JSON converter hands its result straight to this formatter.

❯ Esc
↑ ↓ select ↵ open Shift ↵ new line