JSON Formatter and Validator - Beautify, Minify, Find the Error

2on /
/ Dev Tools / JSON Formatter

JSON formatter and validator

What this JSON formatter does

An API response arrives as one long line and you need to see its shape, or it will not parse at all and you need to know where. This page does both without sending anything anywhere: the parsing, the indentation and the tree view all happen in your browser.

How to use it

  1. 1 Paste the JSON into the box, or press Load an example to see how it behaves.
  2. 2 Choose the indentation, and tick Sort keys if you are comparing two responses.
  3. 3 Press Format. If the JSON is broken you get the line and column; if not, switch to Tree to explore it.

The error message tells you what, not where

Browsers report a broken document differently: some give a character offset, some a line and column, some neither. This page reads whichever form your browser produced and turns it into a line and column, then prints that line with a caret under the exact spot. When no position can be recovered, the message is still shown but no line is marked, because pointing at the wrong line is worse than pointing at none.

Formatting and minifying are the same button, two ways

Both rebuild the document from the parsed value, so the output is always valid JSON even when the input had odd spacing. Minifying strips every space between tokens, which is what you want before putting a payload in a header, a query string or a test fixture.

Before
{"id":7,"tags":["a","b"],"ok":true}
After
{
  "id": 7,
  "tags": [
    "a",
    "b"
  ],
  "ok": true
}

Sorting keys makes two responses comparable

Object keys have no defined order in JSON, so two servers can return the same data in a different sequence and a plain text comparison lights up everywhere. Sorting the keys puts both into the same shape first. Arrays are deliberately left alone: in an array the order is part of the data, not noise.

Nothing you paste leaves this page

JSON that needs formatting is usually a live API response, and it often carries a token, a customer record or an order. There is no upload step here and no server side to this tool: the whole thing runs in the page you already have open.

JSON formatter - frequently asked questions

No. The page has no upload step and no server component; parsing and re-printing happen in the browser tab you are looking at. You can confirm it by loading the page, going offline and formatting anyway.
New
Color Converter Convert a color between HEX, RGB and HSL, build a scale of shades, and check the contrast ratio against white, black or any second color.
Popular Today
Color Converter Convert a color between HEX, RGB and HSL, build a scale of shades, and check the contrast ratio against white, black or any second color.

Related Dev Tools

MD5 Hash Generator Free MD5 hash generator: turn any text or file into an MD5 checksum in your browser - useful for integrity checks and quick fingerprinting.
Base64 Encoder & Decoder Free Base64 encoder and decoder: convert text or files to Base64 and back, entirely in your browser - nothing is uploaded to a server.
Lorem Ipsum Generator Free Lorem Ipsum generator: create placeholder text by paragraph, sentence or word count, with optional HTML tags for your design mockups.
JWT Decoder Free JWT decoder: paste a token to read its header, payload and signature in a readable form - decoding happens in your browser, nothing is sent.
URL Encoder & Decoder Free URL encoder and decoder: convert links and query parameters to percent-encoding and back, with full-URL and component modes, in your browser.

Other Tools You May Like

Word to PDF Convert Word to PDF for free: upload a DOC, DOCX, ODT or RTF file and download a properly formatted PDF in seconds - no registration or watermark.
PDF to Word Convert PDF to Word for free: upload a PDF and download an editable DOCX in seconds - no registration, no watermark and nothing to install.
Word Counter Free word counter: paste any text to count words, characters, sentences and paragraphs, and see the estimated reading time - nothing leaves your browser.
Character Counter Free character counter: count characters with and without spaces, plus words and lines, and check SEO limits for titles and meta descriptions.
Keyword Density Checker Free keyword density checker: paste text or a URL to see how often each word and phrase appears, with percentages for one, two and three-word terms.