We use cookies

We use cookies and similar technologies to enhance your browsing experience, analyze site traffic, and personalize content and ads. By clicking "Accept", you consent to our use of cookies. Learn more in our Privacy Policy.

{ }

JSON Formatter

by Cosmovex

Indent:
Input
Output will appear here

Free JSON Formatter, Viewer & Converter Online

Format, beautify, minify, validate, view as tree, diff, and convert JSON instantly. Auto-fix broken JSON. Query with JSONPath. No signup required. 100% client-side.

Features

  • JSON formatter and beautifier with configurable indentation
  • JSON minifier to compress JSON data
  • JSON validator with error reporting
  • Tree view with expand/collapse and search
  • JSON diff tool — compare two JSON objects
  • Convert JSON to YAML, CSV, Markdown, Key-Value, Query Params, Base64
  • Auto-fix broken JSON — removes comments, trailing commas, fixes Python constants
  • JSONPath query support
  • JSON statistics and structure analysis
  • 8 built-in templates for common JSON structures

More Developer Tools

View all tools →
YAML Formatter
Lint, format & convert YAML
</>
XML Formatter
Beautify & validate XML
CSV Formatter
View & format CSV tables
SQL Formatter
Format & highlight SQL queries
M↓
Markdown Preview
Live Markdown rendering
64
Base64
Encode & decode Base64 strings
JWT
JWT Decoder
Decode & inspect JWT tokens
%20
URL Encoder
Encode & decode URLs

This is a free, in-browser tool for formatting, validating, and exploring JSON. Paste raw JSON, drop a file, or type directly, and it pretty-prints with consistent indentation, reports the first syntax error with a line and column, and lets you read the data in a collapsible tree, a flat table, or the raw text view. It also auto-fixes common mistakes like trailing commas and converts valid JSON to YAML.

Everything runs locally in your browser. The JSON you paste is parsed and rendered on your own machine and is never uploaded to a server, which matters when the payload is an API response, a config file, or a log line that contains tokens, keys, or personal data. There is no account, no upload step, and no size quota beyond what your browser's memory allows, so you can work with production payloads without worrying about where they end up.

How it works and what you get

Paste or open a JSON document and the tool parses it immediately. If it's valid, you can switch between three views:

  • Tree — a collapsible outline of objects and arrays. Useful for inspecting nesting and finding a single value in a large response without scrolling through thousands of lines.
  • Table — arrays of similar objects rendered as rows and columns, which is the fastest way to scan a list of records.
  • Raw — the pretty-printed text, ready to copy back into your editor.

You choose the indentation (2 spaces, 4 spaces, or tabs) and can minify to a single line for sending over the wire. Validation runs as you edit: when parsing fails, you get the reason and the position of the error rather than a generic "invalid JSON" message, so you can jump straight to the offending character.

A worked example

Suppose an API hands you this, all on one line with a stray comma:

{"user":{"id":42,"name":"Ada","roles":["admin","editor",]},"active":true}

Strict JSON rejects the trailing comma after "editor". The auto-fix step removes it, and formatting with 2-space indentation gives you:

{
  "user": {
    "id": 42,
    "name": "Ada",
    "roles": [
      "admin",
      "editor"
    ]
  },
  "active": true
}

Now the tree view shows user as an expandable node and roles as a three-item array, and the YAML conversion produces a flatter, comment-friendly version of the same data. The original input never left the page.

Common use cases

  • Reading API responses. A minified response is unreadable; format it and open the tree to find the field you need.
  • Reviewing config files. package.json, tsconfig.json, app manifests, and CI configs are JSON. Formatting normalises indentation before you commit so diffs stay clean.
  • Debugging logs. Structured log lines are often single-line JSON. Paste one to expand the context, stack frame, or request metadata.
  • Cleaning hand-written JSON. People leave trailing commas and inconsistent spacing; auto-fix and reformat fixes both in one pass.
  • Comparing shapes. Drop two records into table view to confirm they have the same keys.
  • Quick YAML conversion. When a tool wants YAML but you have JSON, convert without installing anything.

Tips and gotchas

A few things that trip people up:

  • Trailing commas are not valid JSON. They're legal in JavaScript object literals, so they sneak in constantly. The auto-fix handles them, but the raw string you paste elsewhere must not contain them.
  • Keys must be double-quoted. {name: "Ada"} is a JavaScript object, not JSON. Keys need "name".
  • No comments allowed. Standard JSON has no // or /* */. If your config uses them (some tools accept "JSONC"), strip them before validating.
  • Single quotes don't count. JSON strings use double quotes only.
  • NaN, Infinity, and undefined are invalid. Use null or a number.
  • Large files render lazily. Tree and table views handle big arrays, but if your browser slows down, switch to raw view, which is lighter.

Why JSON is strict about quotes and commas

JSON is a deliberately small subset of JavaScript's object syntax, defined so that any compliant parser in any language accepts exactly the same documents. That strictness is the point: by banning trailing commas, comments, single quotes, and unquoted keys, the grammar stays unambiguous and easy to implement, which is why JSON works the same in a browser, a Go service, and a Postgres column.

The value types are also fixed: an object ({}), an array ([]), a string, a number, true, false, or null. Notably there is no date type, so dates travel as strings (commonly ISO 8601, like "2026-06-02T10:30:00Z") and your code reparses them. Numbers have no explicit integer/float distinction in the spec, and very large integers can lose precision once they exceed what a 64-bit float represents, which is why IDs are often sent as strings.

Tips

  • Use 2-space indentation for files you'll commit; it keeps diffs small and matches most linters.
  • When a parse fails, read the reported line and column first instead of rereading the whole document.
  • Minify before copying JSON into a URL, a shell argument, or a single-line config value.
  • Switch arrays of records into table view to spot a missing or extra key at a glance.
  • If a config file won't validate, check for trailing commas and comments before anything else.
  • Treat large integer IDs as strings to avoid silent precision loss when they round-trip through JSON.

How to use JSON Formatter & Validator

  1. 1Paste or type your JSON into the input box.
  2. 2It's validated live — errors show the exact line and reason.
  3. 3Switch between raw, tree, table, and stats views to explore the data.
  4. 4Copy the formatted output or download it. Nothing is uploaded.

Frequently asked questions

Is my JSON uploaded anywhere?

No. Parsing, formatting, and conversion all run in your browser. The data you paste stays on your machine, so it's safe to use with API responses or configs that contain secrets.

Why does it reject JSON that works fine in my JavaScript file?

JavaScript object literals allow trailing commas, unquoted keys, single quotes, and comments; strict JSON allows none of those. The auto-fix can clear trailing commas, but the other cases need manual edits.

What does the auto-fix actually change?

It removes common syntax mistakes such as trailing commas before a closing brace or bracket so the document parses, without altering any of your values.

How do I read a deeply nested response quickly?

Format it, then open the tree view and expand only the branches you care about. Collapsed nodes keep the rest of the document out of your way.

Can it handle large files?

Yes, within your browser's available memory. If the tree or table view feels slow on a very large array, switch to raw view, which renders the text without building interactive nodes.

How does the JSON-to-YAML conversion handle data types?

Strings, numbers, booleans, and null map directly to their YAML equivalents, and nested objects and arrays become indented YAML blocks. The result is equivalent data in a format that also supports comments.

Why are my large numeric IDs showing wrong values?

JSON numbers are typically parsed as 64-bit floats, which can't represent every integer above roughly 9 quadrillion exactly. Send such IDs as quoted strings to keep them intact.

Does it support comments in JSON?

Standard JSON has no comments, so a document with // or /* */ will fail validation. Remove them, or strip them first if your source format allows them.

← All toolsRead our guides →