JSON Formatter & Beautifier

Format, beautify and validate JSON instantly. Get the exact line and column of any error, duplicate-key warnings, and a full structure breakdown — all in your browser.

Session History

Formatted JSON from this session will appear here.

    History is kept only in your browser memory for this session and is cleared when you refresh or close the page. Nothing is stored or uploaded.

    All formatting and validation happen locally in your browser — your JSON is never sent to a server. Numbers larger than 2^53 may lose precision, which is a limitation of JSON in JavaScript, not of this tool.

    What It Does

    JSON is the everyday format for API responses, config files and data interchange, but it usually arrives minified onto a single unreadable line, and when it is malformed the built-in browser error is famously unhelpful. This tool fixes both problems. Paste any JSON and it instantly re-indents it into a clean, readable layout (2 spaces, 4 spaces, tabs, or minified), optionally sorting every object's keys. At the same time it validates the document with a strict parser that pinpoints the exact line and column of the first error and explains it in plain English. And because it parses the structure itself, it can tell you things JSON.parse never will: the byte size, the nesting depth, how many objects, arrays and keys there are, and — crucially — whether any duplicate keys are silently throwing away data. Everything runs locally in your browser, so nothing is uploaded.

    When to Use It

    • An API returned a minified blob and you need to read it — paste it here to pretty-print and inspect the structure.
    • Your JSON is being rejected somewhere and you need to know exactly which line and column is wrong, and why.
    • You suspect a config or payload has duplicate keys quietly dropping values, and you want them flagged with their path.
    • You need a canonical form for diffing two JSON documents — sort the keys and minify both so the comparison is clean.

    Worked Examples

    {"name":"Ada","skills":["json","js"],"active":true,"projects":42}

    A normal, valid object delivered on one line. It is pretty-printed and the insight panel reports the key count, depth and value types.

    {"id":1,"name":"first","id":2}

    Contains a duplicate key. JSON.parse would silently keep id=2 and discard id=1. The tool flags the duplicate, its path and line so you do not lose data unknowingly.

    {"a":1,"b":[1,2,3],}

    Has a trailing comma before the closing brace — invalid JSON. The tool reports the exact line and column and explains that trailing commas are not allowed.

    {"user":{"profile":{"address":{"geo":{"lat":12.9,"lng":77.5}}}}}

    Deeply nested. The structure breakdown highlights the maximum nesting depth, which is easy to miss when reading minified JSON.

    Features

    Pretty-print with 2-space
    4-space or tab indentation
    One-click minify to the most compact valid JSON
    Recursive alphabetical key sorting for canonical output
    Strict validation with exact line and column on errors
    Error context view that points a caret at the problem
    One-click Repair for trailing commas
    single quotes
    unquoted keys and comments
    Duplicate-key detection with path and line number
    Collapsible tree view for exploring nested data
    Structure stats: bytes
    keys
    objects
    arrays and max depth
    Import a .json file by browse or drag-and-drop
    Download the formatted result as a file
    In-memory session history that clears on refresh
    Live formatting as you type with copy and clear
    Fully browser-based with no server uploads

    How to Use

    1. Paste or type your JSON into the input area. 2. Choose an indentation style (2/4 spaces, tab) or pick Minify. 3. Optionally enable Sort keys for canonical output. 4. Read the formatted result, and check the insight panel for size, structure and duplicate-key warnings. 5. If the JSON is invalid, the exact line, column and reason are shown. 6. Click Copy to copy the result or Clear to reset.

    Common Mistakes

    • Using single quotes. JSON requires double quotes for every key and string value — single quotes are a JavaScript habit that JSON rejects.
    • Leaving a trailing comma. A comma before a closing } or ] is valid in JavaScript and many languages, but not in JSON.
    • Assuming duplicate keys are harmless. Parsers keep only the last value and drop the rest with no warning — always check for duplicates.
    • Forgetting JSON has no comments. // and /* */ comments are not part of JSON and will cause a parse error.
    • Treating large numbers as safe. Integers beyond 2^53 lose precision when parsed into JavaScript numbers — keep very large IDs as strings.

    Frequently Asked Questions