JSON Formatter
Share with friends
How to use
- 1 Paste your JSON into the input box. Both compact and pretty-printed JSON work as input.
- 2 Choose indentation: 2 spaces (popular for web/JS), 4 spaces (Python style), or tab.
- 3 Click Format to pretty-print, or Minify to compact to a single line.
- 4 If JSON is invalid, the error message shows the line and column where parsing failed — common causes are trailing commas, single quotes, or unquoted keys.
- 5 Copy the formatted output to your clipboard with one click.
About JSON Formatter
FAQ
Q Why is my JSON invalid even though it looks fine?
The most common causes are: trailing commas after the last array element or object key, single-quoted strings (JSON requires double quotes), unquoted object keys, JavaScript-style comments, or smart curly quotes from a word processor. The validator's line and column number points to the exact spot.
Q Can JSON have comments?
Strict JSON (RFC 8259) does not allow comments. JSONC (used in VS Code config files) and JSON5 do allow them, but most APIs reject anything but strict JSON. If you need comments in a config, use YAML or strip them before parsing.
Q What is the difference between JSON and JavaScript objects?
JSON is a strict text format with double-quoted keys and no trailing commas. JavaScript object literals are more permissive (unquoted keys, single quotes, trailing commas, comments). JSON is a subset of valid JavaScript syntax — every JSON document is valid JS, but not every JS object literal is valid JSON.
Q How big can a JSON file be?
No standard limit, but practical limits depend on the parser. Browsers can typically handle 50–100 MB before slowing. APIs commonly cap requests at 1–10 MB. For documents over 100 MB consider streaming parsers (JSONStream in Node.js, ijson in Python) that don't load the whole document into memory.
Q Should I use 2 or 4 space indent for JSON?
Two spaces dominate JavaScript and web ecosystems (npm package.json, most APIs); four spaces are common in Python (json.dumps default) and some Java tooling. Either is valid. Pick one and be consistent within a project — most linters auto-format to project preference.
Q Is my data sent to a server when I use this formatter?
No. The formatter runs entirely in your browser using built-in JSON.parse and JSON.stringify functions. Your data never leaves your device. You can verify this by opening DevTools network tab while formatting — there are no requests.
Q How do I escape special characters in a JSON string?
Use backslash escapes: <code>\"</code> for double quote, <code>\\</code> for backslash, <code>\n</code> for newline, <code>\t</code> for tab, <code>\u00E9</code> for any Unicode codepoint. Forward slashes can optionally be escaped <code>\/</code> but it's not required by RFC 8259.
Q Why does my number lose precision in JSON?
JSON numbers map to IEEE 754 double-precision floats in most parsers, giving 15–17 significant digits. Large integers like Twitter snowflake IDs or 64-bit database IDs lose precision when parsed. APIs often serialize them as strings ("id": "1234567890123456789") to preserve exact value.
Official resources
IETF RFC 8259 — JSON Data Interchange Format
Authoritative IETF specification of the JSON syntax and parsing rules.
ECMA-404 — JSON Data Interchange Standard
ECMA International formal specification of JSON, technically equivalent to RFC 8259.
json.org — Original JSON Specification
Douglas Crockford's original JSON specification page with grammar diagrams.
MDN — JSON.parse()
MDN Web Docs reference for the native JavaScript JSON parser used in browsers.