Skip to the tool
ToolOcean

Free JSON Formatter Online

Paste messy or minified JSON and get it back properly indented and validated. Syntax errors are reported with the exact line and column, so you can fix them instead of hunting for them.

Runs in your browser. Nothing is uploaded.

How to format JSON in three steps

  1. Step 1: Paste or open your JSONPaste into the left editor, drag a .json file onto it, or press "Open file". Files are read locally with the FileReader API, picking a file is not an upload.
  2. Step 2: Format, minify or validateAuto format runs as you type. Or press Beautify for indented output, Minify to strip whitespace, or Validate to check the document without changing it.
  3. Step 3: Copy or download the resultCopy to the clipboard in one click, or save it as formatted.json. The status bar reports size, line count, total keys and nesting depth.

Good to know

  • It is not a JSON Schema validator
  • Very large documents run on the main thread
  • Reformatting is not byte-preserving for numbers
  • No diffing, no querying, no streaming

About this tool

What this formatter does differently

Most online JSON formatters post your document to a server, format it there, and send it back. That is a poor trade for something a browser can do natively in under a millisecond, and it means every API response you debug, tokens, customer records, internal IDs, lands in somebody else's request log. This page has no backend at all. The formatting runs in the tab you are reading, which is why it is safe to paste production data into.

The other difference is error reporting. Browsers word their JSON syntax errors inconsistently and Safari does not report a position at all, so this tool normalises the message and derives a line and column number, then highlights that line in the gutter. For a 4,000-line config file, that is the difference between a five-second fix and a bisect.

  • Runs in your browser. All processing happens locally in this tab using JavaScript.
  • No uploads. Your data is never sent to a server. There is no server to send it to.
  • Works offline. Once the page has loaded you can disconnect and keep working.
  • Unlimited & free. No usage caps, no paywall, no file size tiers.

Format JSON. Choose a JSON file

What happens to your data

The same questions a security review would ask, answered plainly.

Read via
Typed or pasted into the page
Held in
Your browser tab's memory for as long as it is open
Stored
Nothing. No cookies, no database, no server-side copy
Transmitted
Nothing leaves your device
Retained after you close the tab
Nothing
Works offline
Yes, once the page has loaded

Why use this JSON formatter

What you get here that a server-side formatter cannot offer.

  • Nothing is uploaded

    There is no server to send your JSON to. The page is a static bundle, and the formatting happens in local JavaScript, check your network panel while you use it.

  • Errors with a line and column

    Invalid JSON gets a normalised message plus the exact position, highlighted in the gutter. Trailing commas, single quotes, unquoted keys and stray comments are all pinpointed.

  • Handles large documents

    The editor renders line numbers as a single text node rather than one element per line, so multi-megabyte files stay responsive. Format-as-you-type pauses above 512 KB to keep typing smooth.

  • Beautify and minify

    Switch between 2, 3, 4-space and tab indentation, or strip every byte of whitespace for production. Live byte, line, key and depth counts show the effect.

  • Optional alphabetical key sort

    Sorting object keys makes two versions of the same config diffable. Array order is always preserved, because reordering an array changes what the document means.

  • Keyboard driven

    ⌘/Ctrl+Enter formats, ⌘/Ctrl+Shift+M minifies, ⌘/Ctrl+Shift+C copies the output and ⌘/Ctrl+S downloads it. Tab inserts spaces instead of leaving the editor.

JSON formatting examples

Real input, real output, and what changed in between.

Beautify a minified API response

The usual case: a single-line response body copied out of a network panel or a log.

Inputjson
{"id":42,"name":"Ada Lovelace","active":true,"roles":["admin","editor"],"meta":{"created":"2024-01-15T09:30:00Z","score":98.5}}
Outputjson
{
  "id": 42,
  "name": "Ada Lovelace",
  "active": true,
  "roles": [
    "admin",
    "editor"
  ],
  "meta": {
    "created": "2024-01-15T09:30:00Z",
    "score": 98.5
  }
}

The data is untouched, only whitespace changed. Nested objects and arrays each gain a level of indentation, which is what makes the structure scannable. Formatting is purely presentational, so you can safely paste the result back into the system it came from.

Find a trailing comma

Valid in JavaScript, invalid in JSON. The single most common reason a config file fails to parse.

Inputjson
{
  "name": "checkout-service",
  "retries": 3,
}
Outputjson
Expected double-quoted property name, line 4, column 1

The comma after 3 on line 3 is the mistake, but the error points at line 4. That is not a bug: the parser accepts the comma, then expects another property name and instead finds the closing brace, so the first position it can definitively call invalid is line 4. When a reported line looks fine, the cause is almost always the line above it.

Minify for production

Strip every non-essential byte before embedding JSON in a bundle or a config value.

Inputjson
{
  "id": 42,
  "name": "Ada Lovelace",
  "active": true,
  "roles": [
    "admin",
    "editor"
  ],
  "meta": {
    "created": "2024-01-15T09:30:00Z",
    "score": 98.5
  }
}
Outputjson
{"id":42,"name":"Ada Lovelace","active":true,"roles":["admin","editor"],"meta":{"created":"2024-01-15T09:30:00Z","score":98.5}}

Minifying this example drops it from 176 bytes to 127, a 28% reduction, entirely from removing whitespace. The saving scales with nesting depth, so deeply structured documents benefit most. Over HTTP with gzip or brotli the real-world difference is smaller, since compression already handles repeated indentation well.

Who uses a JSON formatter

Debugging an API

Paste a response body straight from your browser's network panel or a curl call. Because nothing is transmitted, this works for authenticated endpoints and staging data that you could not paste into a hosted formatter.

Editing config files

tsconfig.json, package.json, ESLint and CI configs all fail loudly on a stray comma. Validate before committing, and use key sorting to make a large config reviewable in a diff.

Backend development

Check the exact shape of a payload before writing a deserialiser, or confirm what your service actually emitted rather than what the schema says it should.

Frontend development

Inspect fixture files and mock responses, and minify JSON that ships inside a bundle. The depth and key counts help spot a response that has grown heavier than intended.

Learning JSON

Indentation makes the relationship between objects and arrays visible. Deliberately breaking a document and reading the error is a fast way to internalise the strict rules that separate JSON from JavaScript.

Working with regulated data

Where policy forbids pasting customer records into third-party sites, a formatter that provably makes no network requests is often the only compliant option available.

Good to know

The honest edges, and where to go instead when you hit one.

It is not a JSON Schema validator

Valid JSON and correct JSON are different questions. This tool tells you the document parses; it has no opinion on whether a field is missing, a type is wrong, or an enum is out of range.

Use JSON Schema Validator instead →

Very large documents run on the main thread

Parsing and re-serialising happen in the page rather than a worker, so a document in the tens of megabytes will make the tab unresponsive while it works. A few megabytes is comfortable; a 200 MB export is not what this is for.

Reformatting is not byte-preserving for numbers

Values pass through JavaScript numbers, which are IEEE-754 doubles. An integer larger than 9,007,199,254,740,991. A Twitter-style ID, say, comes back rounded, and the output will be valid JSON that no longer says what the input said.

No diffing, no querying, no streaming

This formats one document at a time. Comparing two payloads, running a JSONPath expression over one, or reading a file too big to hold in memory are all different jobs that this page deliberately does not try to do.

Use Text Diff Viewer instead →

JSON formatter FAQ

Common questions about formatting, validating and the strict rules JSON enforces.

How do I format JSON?

Paste your JSON into the left editor. With auto format on it is indented immediately; otherwise press Beautify or ⌘/Ctrl+Enter. Pick your indentation, 2, 3 or 4 spaces, or tabs, then copy the result or download it as a file.

Is my JSON uploaded to a server?

No. This page has no backend. The formatter is JavaScript that runs in your browser, so your JSON never leaves the tab. You can verify it by opening DevTools, switching to the Network tab, and formatting a document, no request is made.

What is the difference between beautifying and minifying JSON?

Both keep the data identical and only change whitespace. Beautifying adds newlines and indentation so a human can read the structure. Minifying removes all optional whitespace to make the payload as small as possible, which suits anything that gets transmitted or embedded in code.

Why is my JSON invalid when it looks like valid JavaScript?

JSON is much stricter than JavaScript object syntax. It forbids trailing commas, requires double quotes around both keys and string values, disallows comments, and rejects single quotes, unquoted keys, undefined, NaN and Infinity. A JavaScript object literal that works fine in code is frequently invalid JSON.

Can I use comments in a JSON file?

Not in standard JSON. The specification has no comment syntax, so this validator rejects them. Some tools accept a superset called JSONC (used by tsconfig.json and VS Code settings) which does allow // and /* */. If you need comments, keep the file as JSONC and strip them before handing it to a strict parser.

Can this tool fix invalid JSON automatically?

This page reports errors rather than guessing at repairs, because a wrong guess silently changes your data. For automatic repair of the common cases, trailing commas, unquoted keys, smart quotes, use the JSON Fixer, then bring the result back here to format it.

How large a JSON file can I format?

There is no limit set by us. The constraint is your device's memory, since the whole document is held in RAM. Files in the low tens of megabytes are fine on a laptop; format-as-you-type switches off above 512 KB so typing stays responsive, and you press Beautify instead.

Does it work offline?

Yes, once the page has loaded. The formatter is already on your machine at that point, so you can disconnect and keep working. Reloading while offline depends on the page still being in your browser cache.

Will formatting change my data?

Formatting only alters whitespace, so the parsed value is identical. There are two things worth knowing, though: very large integers and duplicate keys are affected by the parse step itself, see the next two answers.

Why did my very large numbers change?

JSON.parse produces JavaScript numbers, which are IEEE-754 doubles and can only represent integers exactly up to 9,007,199,254,740,991. An ID like 12345678901234567890 loses precision on the way in, and the formatted output will show the rounded value. If you handle large integers such as Twitter-style snowflake IDs or int64 database keys, transport them as strings.

What happens to duplicate keys?

JSON technically permits repeated keys but does not define what they mean. JavaScript keeps the last one, so {"a":1,"a":2} formats to {"a": 2} and the first value is silently dropped. If a document surprises you by losing a field, duplicate keys are worth checking for.

Does sorting keys change the meaning of my JSON?

No. Object key order is not significant in JSON, so sorting is safe and makes two versions of a config genuinely diffable. Array order is significant and is never touched. One caveat: JavaScript engines always place integer-like keys such as "2" and "10" first, in numeric order, regardless of sorting.

Can I format JSON Lines or NDJSON?

Not directly. JSON Lines files contain one independent JSON document per line, so the file as a whole is not valid JSON and will fail validation. Format one line at a time, or wrap the lines in an array with commas between them first.

What keyboard shortcuts are available?

⌘/Ctrl+Enter beautifies, ⌘/Ctrl+Shift+M minifies, ⌘/Ctrl+Shift+C copies the output and ⌘/Ctrl+S downloads it. Tab inserts two spaces inside the editor; Shift+Tab still moves focus out, so you are never trapped in the field.

Do I need an account?

No. There is no sign-up, no email and no usage limit. Nothing about your session is stored beyond the tab you have open.

Is my text uploaded to a server?

No. JSON Formatter is a static page with no backend. Your text is read and processed by JavaScript running in this tab, and it is never transmitted. You can confirm this by opening your browser's network panel while you use the tool. There are no outbound requests.

How much data can I paste in?

There is no server-side cap. Very large inputs are limited only by your device's memory and will make the page feel slower, since the work happens on the main thread. In practice a few megabytes of text is comfortable.

Do I need to create an account?

No. There is no sign-up, no email, and no usage tracking tied to an identity. The tool works the first time you open it.