Format Code Now
/
Format & validateJSON Syntax Highlighting Next: XML Highlighter ›

JSON Syntax Highlighting

FV-55

Paste JSON to see its keys, strings, numbers and literals in separate colors. The JSON is validated first, and you can pretty print it, keep your layout or minify it before copying the colored HTML.

Runs in your browser. Nothing is uploaded.

JSON

Highlighted JSON

How to use it

  1. Paste your JSON, or open a .json file.
  2. Pick a layout: indent with 2 spaces, 4 spaces or tabs, keep it as written, or minify.
  3. Choose the Light or Dark theme and switch line numbers on or off.
  4. Press Copy HTML or Download to take the colored block with you.

Checked before it is colored

The tool parses the JSON before it colors anything. If there is a problem, such as a trailing comma, a missing quote or a comment, the status line names it with its line and column and nothing is colored. Comments and trailing commas are rejected because they are not part of JSON. Valid input shows the number of lines in the status line.

Values stay exactly as written

Numbers and strings are copied from your input character for character. A 20 digit ID such as 12345678901234567890 is not rounded, 3.50 keeps its trailing zero and an escape such as \u00e9 is shown as typed. Pretty printing and minifying change only the whitespace between tokens, never the values or the key order.

Error messages and what to do

MessageWhat it meansFix
Expected a string keyInside an object the parser wanted a key in double quotes, often because of a trailing comma or an unquoted key.Quote the key, or remove the comma before the closing brace.

Questions people ask

What does each color mean?

Keys get one color, string values another, and numbers, true, false and null share a third. Punctuation such as braces, brackets, colons and commas stays in the plain text color. The Light and Dark themes use the same roles with colors chosen for each background.

Can I highlight invalid JSON?

No. The tool checks the JSON first and shows the error with its line and column instead of coloring it. This is on purpose: you know that anything it colors is valid. To color JSON-like text with comments, use the code highlighter with JavaScript selected.

Does pretty printing change my data?

No. Only whitespace changes. Keys keep their order, duplicate keys are kept as written, numbers keep their digits and strings keep their escapes. Minified removes every space and line break between tokens; As written keeps your own layout.

How do I put highlighted JSON in documentation?

Press Copy HTML and paste into an editor that accepts HTML. The block is a pre element with an inline style on every colored span, so it needs no stylesheet. Download saves the same block as an .html file you can open or attach.

Is my JSON sent to a server?

No. Parsing, formatting and coloring all happen in your browser. Nothing you paste is uploaded or stored, and the downloaded file is created on your device.

About this tool

Keys, strings, numbers and true, false and null each get their own color. The JSON is checked first, and an error names the line and column of the problem. Numbers and strings are shown exactly as written, so 12345678901234567890 and 3.50 are not rounded or changed, and escape sequences stay as typed. Pretty printing changes only whitespace; As written keeps your layout; Minified removes all whitespace between tokens. Copy HTML and Download give a <pre> block with inline colors. Comments and trailing commas are not allowed, because they are not JSON.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.