JSON Formatter and Validator

A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call

Free JSON formatter and validator. Beautify JSON with 2 or 4 spaces or tabs, minify it, sort keys, and see exactly where an error is.

Status
0
Top level
0
Keys
0
Size
0
Formatted JSON

Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.

How to use the JSON formatter

Paste your JSON into the box. The JSON formatter checks it straight away and shows it neatly formatted, ready to copy:

  • Format with 2 spaces, 4 spaces or tabs, or choose Minify to remove all unnecessary spaces and line breaks.
  • Sort keys A to Z to put every object's keys in alphabetical order, at every level. That makes two versions of the same data much easier to compare.
  • Status shows whether the JSON is valid; Top level shows whether it's an object, array or single value; Keys counts the keys in every object; Size shows the size of the result in bytes.

If the JSON is invalid, the formatter shows the error with its line and column, and a plain-English hint for the most common causes: trailing commas, single quotes, comments and unquoted keys. It also warns if your JSON contains numbers too long for JavaScript to store exactly.

Everything happens in your browser. Your JSON, which might contain customer data, API keys or private settings, is never uploaded.

What JSON is

JSON (JavaScript Object Notation) is a simple text format for structured data. It's used almost everywhere data moves between systems: web APIs, configuration files, exports from apps, webhooks, analytics tools, and the structured data on web pages.

JSON is built from a few pieces:

  • Objects: { "name": "Seeded rye", "price": 6.5 }, a set of keys and values in curly braces.
  • Arrays: [1, 2, 3], an ordered list in square brackets.
  • Strings: text in double quotes, "Crumb & Co.".
  • Numbers: 6.5, -12, 1.2e3.
  • true, false and null.

Values can be nested: an object can contain arrays of objects, and so on.

Why format JSON?

Machines don't care about spacing, so JSON from APIs and exports often arrives as one long line. Formatting (also called beautifying or pretty-printing) adds indentation and line breaks so people can read it:

{
  "business": "Crumb & Co.",
  "open": true,
  "hours": {
    "weekdays": "07:00-15:00"
  }
}

Formatted JSON makes it easy to:

  • see the structure of an API response,
  • find a particular value,
  • spot missing or unexpected fields,
  • review changes to configuration files,
  • compare two versions with the text compare tool (sort the keys first for the clearest comparison).

Minifying does the opposite: it removes all the formatting to make the JSON as small as possible, which is useful for sending it over a network or storing it compactly.

Common JSON errors, and how to fix them

JSON is strict. These are the mistakes that cause most "invalid JSON" errors, and the JSON formatter gives a hint for each:

Trailing commas

{ "a": 1, "b": 2, }

JavaScript allows a comma after the last item; JSON doesn't. Remove the comma before } or ].

Single quotes

{ 'name': 'Seeded rye' }

JSON requires double quotes around keys and text. Replace ' with ".

Unquoted keys

{ name: "Seeded rye" }

Every key must be in double quotes: { "name": "Seeded rye" }.

Comments

{ "price": 6.5 // per loaf }

JSON has no comments. Remove them, or move the information into a field such as "note".

Other causes

  • Missing commas between items.
  • Unescaped quotes or line breaks inside strings: write \" and \n.
  • Special values like NaN, Infinity or undefined, which aren't JSON.
  • Copying from a document or chat that turned straight quotes into curly quotes (“ ”). Replace them with straight quotes; the find and replace tool helps.

The error message tells you where the parser gave up, which is usually at or just after the real mistake.

Large numbers and precision

JavaScript stores numbers as 64-bit floating point, which can represent whole numbers exactly only up to 9,007,199,254,740,991 (2⁵³ − 1). Longer numbers, such as some database IDs, order numbers or social media post IDs, can silently change when JSON is parsed and formatted:

12345678901234567890  →  12345678901234567000

The JSON formatter warns you when your JSON contains numbers with 16 or more digits. The fix is to store long IDs as strings in quotes, which is why many APIs send IDs as "id": "12345678901234567890".

JSON in everyday business work

You don't have to be a developer to meet JSON:

  • Exports and integrations: Zapier, Make, Shopify, Stripe and many other tools show data as JSON.
  • Webhooks: notifications from payment or booking systems arrive as JSON.
  • Website settings: web manifests, theme settings and app configurations.
  • SEO: structured data such as FAQ, product and organization schema is written in JSON-LD. Our product schema generator and others produce it, and the JSON formatter checks it if you edit it by hand.
  • AI tools: many AI and automation tools take or return JSON.

To turn JSON into a spreadsheet, or a spreadsheet into JSON, use the CSV to JSON converter. To decode values in links, use the URL encoder and decoder; for timestamps such as 1700000000, use the Unix timestamp converter.

2 spaces, 4 spaces or tabs?

There's no single right answer:

  • 2 spaces is the most common for JSON in web projects and keeps deeply nested data from drifting off the screen.
  • 4 spaces is easier to scan for some people and common in Python projects.
  • Tabs let each person choose how wide indentation looks in their editor.

If you're editing a file in a project, match the existing style.

Privacy and security

JSON often contains things you shouldn't paste into random websites: customer details, internal IDs, access tokens, API keys. Many online JSON formatters send your data to their servers. This one doesn't: the JSON is parsed and formatted by your browser, on your device, and nothing is uploaded or stored. You can even disconnect from the internet after the page has loaded and it will keep working.

Even so, treat API keys and passwords as secrets: don't share screenshots or copies of JSON that contains them.

Reading an API response

When you first see a large JSON response from an API or an export, it can look overwhelming. A quick way in:

  1. Format it with 2 spaces, so the structure is visible.
  2. Look at the top level. Is it an object with a few keys, or an array of records? The formatter's "Top level" tells you.
  3. Find the list you care about, such as orders, items or data, and look at one record in it.
  4. Note the keys of one record: names, IDs, dates, amounts. These are the "columns" if you turn the data into a spreadsheet.
  5. Check types: are prices numbers or text? Are dates written as text or as timestamps?

Once you know the shape of one record, the rest of the file usually follows the same pattern, and you can convert the list to CSV with the CSV to JSON converter's JSON-to-CSV option.

A worked example

A bakery's ordering system sends a webhook to a spreadsheet integration, and the integration keeps failing. The owner copies the webhook's body from the log: one long line of text. Pasted into the JSON formatter, it shows "Invalid", an error at line 1, and the hint "There may be a comma after the last item". The JSON had been edited by hand in a test, leaving "total": 24.5,} at the end.

After removing the comma, the formatter shows "Valid", formats it with 2 spaces, and the owner can see every field clearly, including the order_id, which the formatter flags as a 19-digit number that may lose precision. The owner asks the developer to send IDs as strings, and the integration works.

Need more customers from Google?

This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit manages Google Ads for small and mid-size businesses, and only Google Ads. We check your account before we ever get on a call, then fix the structure, the keywords, the tracking and the ads, with month-to-month terms and no long contract. Book a free audit call.

Frequently asked questions

How do I format JSON?

Paste it into the JSON formatter and choose 2 spaces, 4 spaces or tabs. The formatted JSON appears instantly, ready to copy.

How do I minify JSON?

Choose Minify in the format options. All unnecessary spaces and line breaks are removed.

Why is my JSON invalid?

Most often because of a trailing comma, single quotes, unquoted keys or comments. The JSON formatter shows the line and column of the error and a hint.

Can it validate JSON?

Yes. The status shows whether your JSON is valid, and errors are explained with their position.

Is my data safe?

Yes. The JSON formatter runs in your browser and never uploads what you paste.

Is the JSON formatter free?

Yes. It's free with no sign-up and no size limits beyond what your browser can handle.

Free PPC audit

See where your ad budget leaks.

We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.

Book a free audit call 30-minute call · Free · The audit is yours to keep