Layerbit
Runs entirely in your browser

JSON Formatter, Validator & Schema Tool

Format, validate, minify and repair JSON, JSON5, JSONC and JSON Lines, or convert YAML, TOML and XML in. View it as a tree, an editable table or an editable graph; query it with JSONPath, JMESPath, JSON Query or jq; compare two documents; validate, infer, edit or sample a JSON Schema; generate types for 7 languages; export SQL, CSV, YAML, TOML and XML. Numbers keep every digit, files of 50 MB and more open in a background worker, and nothing leaves your browser.

Raw JSON Input
Invalid JSON format.
Result

Everything a JSON document needs, in one place

Formatting is where JSON work starts, not where it ends. The same payload gets queried for one value, checked against a contract, turned into types for the code that consumes it, and loaded into a table. Each of those is a tab on the result pane, and each runs on the parsed document already in your browser.

Fix almost-JSON

Comments, trailing commas, single quotes, bare keys, NaN, Python's True/None, smart quotes from a document, a byte-order mark — the usual reasons a parser rejects something that is obviously meant as JSON. The Fix button rewrites exactly those and tells you what it changed, so you can judge whether the result is what the author meant.

JSONPath queries

Not just dotted paths: wildcards, recursive descent ($..id), negative indexes, slices, unions and filter expressions such as $.orders[?(@.total > 100 && @.status == "paid")]. Every match is listed with its full path, which is what you paste into the code that reads it.

JSON Schema, both ways

Paste a schema and validate the document against it with errors by path and keyword — type, required, enum, format, pattern, ranges, $ref, oneOf, if/then. Or infer a schema from the document: types, required keys, nullable fields, formats such as date-time and email, and enums for repeated string values.

Types for seven languages

TypeScript interfaces, Go structs with tags, C# classes with JsonPropertyName, Kotlin data classes, Python dataclasses, Java records and Rust serde structs — inferred from a sample, with optional fields where a key is sometimes missing and nullable types where a value is sometimes null.

SQL and CSV export

An array of objects becomes a CREATE TABLE with inferred column types and batched INSERTs for PostgreSQL, MySQL or SQLite, nested objects flattened into parent_child columns. Or a CSV with the same flattening, ready for a spreadsheet.

NDJSON and big documents

Log exports and streaming APIs produce one JSON object per line. Those are detected and parsed line by line, with per-line error reporting, and can be converted to an array or back. Documents of tens of megabytes format in well under a second; the tree view keeps them navigable.

Quick Testing Templates

Click a template to load it. The broken one shows the error position and the Fix button; the API response is the one to try Query, Schema, Types and SQL on.

What "valid JSON" actually means

JSON is specified by RFC 8259, and the grammar is deliberately tiny — six structural characters, four literals, strings, and numbers. That small surface is why it won, and it is also why so much of what people write is almost JSON. This validator uses the browser's native JSON.parse(), so what passes here is exactly what will pass in your runtime, not a looser approximation of it.

Trailing commas

{"a": 1,} is invalid. JavaScript object literals allow a trailing comma and JSON does not, which is why hand-edited config files break after someone deletes the last entry. This is the single most common parse failure, and the first thing Fix removes.

Single quotes

{'a': 1} is invalid. JSON strings must use double quotes, for both keys and values. Output copied from a Python repr() or a JavaScript console almost always needs this fixed.

Unquoted keys

{a: 1} is invalid. Every key is a string and must be quoted. JavaScript permits bare identifiers as keys; JSON never does.

Comments

Neither // nor /* */ is legal JSON. Formats that appear to allow them — tsconfig.json, VS Code settings — are JSON with Comments (JSONC), a different format parsed by a different reader.

NaN and Infinity

Not valid JSON values, despite being valid JavaScript numbers. A serialiser that emits them produces output no conforming parser will read — JSON.stringify converts them to null for exactly this reason.

Leading zeros and +

01, +1 and .5 are all invalid numbers. JSON requires 1, 1 and 0.5. Hex literals such as 0xFF are invalid too.

The precision problem nobody warns you about

JSON numbers have no specified size limit, but JavaScript parses them into IEEE 754 doubles, which hold integers exactly only up to 253 − 1. Beyond that, parsing silently loses precision:

  • {"id": 9007199254740993} parses to 9007199254740992 — quietly off by one.
  • Twitter/X snowflake IDs, Discord IDs and many database bigint primary keys exceed this range routinely.
  • No error is raised. The number simply changes, and you find out when a lookup by ID misses.

This is why mature APIs serialise large identifiers as strings. If you control the producer, do the same. If you do not, parse with a library that supports BigInt rather than the native parser. This page scans the raw text for integers beyond that range and warns you above the input — the document is valid; the round trip through a double is what loses information. Beautify, Minify and Sort keys here do not make that round trip: the output keeps every number exactly as written, including 1e400 and -0, which JSON.stringify would turn into null and 0.

Schema validation, briefly

A JSON Schema is a contract: it says which keys must exist, what type each value has, which strings are dates or emails, what a status field may contain. Validating a payload against it before you process it turns a vague runtime failure three functions deep into a precise message at the boundary — $.orders[2].total: expected number, got string. The validator here covers draft-07 and the 2020-12 keywords most schemas use: type, properties, required, additionalProperties, items, enum, const, format, pattern, numeric and length bounds, uniqueItems, local $ref, allOf/anyOf/oneOf/not, and if/then/else.

Inferring a schema from a sample is the fast way to get one. The inference marks a key as required only if every object in the sample has it, types a field as nullable only if a null was actually seen, and proposes an enum only when a string field repeats a small set of values. Treat the result as a draft: it describes the sample you gave it, not every document the producer might emit.

Minify, beautify, and what each is for

Both operations preserve the data exactly and change only the whitespace, but they serve opposite purposes. Beautifying is for reading, reviewing and diffing — a formatted file produces line-level diffs a human can review, whereas a minified one produces a single enormous changed line. Minifying strips every unnecessary byte for transmission and storage.

One caveat worth knowing: neither operation guarantees key order is meaningful. RFC 8259 defines an object as an unordered collection, so while JSON.parse and JSON.stringify happen to preserve insertion order in practice, you should never rely on ordering as data. If order matters, use an array. If you want a canonical form for comparison, enable Sort keys — or send both documents to the diff tool, whose structural mode ignores order entirely.

Why this runs in your browser

API responses are exactly the kind of thing that contains bearer tokens, customer email addresses, internal identifiers and occasionally a password reset link. Pasting that into a server-side formatter means handing it to infrastructure you cannot inspect. Everything here happens in the page: parsing, repair, queries, schema validation, type generation and SQL export are all local JavaScript. The indicator in the header counts network requests the page makes; it stays at zero while you work.

Frequently Asked Questions

Paste the JSON into the left pane and press Beautify. Choose 2 spaces, 4 spaces or tabs for the indentation; Sort keys orders every object alphabetically, which makes two versions easy to compare. Minify does the opposite and removes all whitespace. If the JSON has an error, the line and column are shown, and Fix repairs common problems such as trailing commas, single quotes and comments, listing each change it made.

Unlike server-side validation tools that transmit your pasted data across the internet, Layerbit executes all parsing and formatting locally within your machine using the browser's native JSON.parse() capabilities. Sensitive API keys, private user data and proprietary system configurations remain strictly on your device, and the header indicator shows the page has made no network request with your data. Nothing is saved on your device either, unless you turn on Save to history; then only the runs you start yourself are kept, in this browser, until you clear them.

It applies a fixed list of rewrites outside of string values: it removes comments and trailing commas, converts single and smart quotes to double quotes, quotes bare keys, replaces NaN, Infinity and undefined with null, converts Python's True, False and None, strips a byte-order mark, and inserts a comma between values that sit on consecutive lines without one. Each change is listed so you can review it. It never guesses at missing brackets or reorders data; if the result still does not parse, the error position tells you what is left.

The root $, dotted keys, bracket keys with quotes for names containing spaces, numeric and negative indexes, wildcards with [*] or .*, recursive descent with .., slices such as [0:5], unions such as [0,2] or ['a','b'], .length on arrays and strings, and filters written as [?(@.price > 10 && @.status == 'paid')] with ==, !=, <, >, <=, >=, regex matching via =~ /pattern/, negation and parentheses. Every match is returned with its exact path.

type (including integer and type arrays), properties, patternProperties, additionalProperties, propertyNames, required, dependentRequired, minProperties and maxProperties, items and prefixItems, contains, minItems, maxItems and uniqueItems, enum and const, minimum, maximum, exclusiveMinimum, exclusiveMaximum and multipleOf, minLength, maxLength, pattern and format (date-time, date, time, email, uri, uuid, ipv4, ipv6, hostname, regex), local $ref to definitions or $defs, allOf, anyOf, oneOf and not, and if, then and else. Remote $ref URLs are not fetched, because nothing on this page makes network requests.

The generator walks every object in the sample. A key present in some objects of the same shape but not others becomes optional (a ? in TypeScript, omitempty in Go, Optional in Python). A value that is null in at least one place becomes nullable. A field that is sometimes an integer and sometimes a decimal becomes a floating-point type. Arrays merge the shapes of all their elements. Give it a representative sample with a few records rather than one, and the result reflects the real variation.

Each column's values are examined across every row: all integers gives BIGINT (INTEGER in SQLite), any decimal gives DOUBLE PRECISION, booleans give BOOLEAN or TINYINT(1), ISO date strings give TIMESTAMP or DATETIME, and everything else gives TEXT or a VARCHAR sized from the longest value. A column with no nulls is marked NOT NULL. Nested objects are flattened into parent_child columns and arrays are stored as JSON text. Identifiers are converted to snake_case and quoted for the chosen dialect.

Excel, LibreOffice and Google Sheets treat a cell that begins with =, +, - or @ as a formula, so a value such as =HYPERLINK("http://…") in your data can run when someone opens the file (CSV or formula injection). With Safe for Excel on, which is the default, such values are written with a leading apostrophe ('=HYPERLINK(…)); spreadsheets show them as text. Plain numbers such as -5 or +3.5 are left alone. Turn it off when the CSV feeds another program that must receive the exact text.

Yes: pick the format in the menu beside Sort keys (opening a file picks it from the extension). JSONC is JSON with comments and trailing commas, as in VS Code settings and tsconfig.json. JSON5 also allows unquoted keys, single quotes, hexadecimal numbers, leading or trailing decimal points and Infinity/NaN; JSON has no way to write the last two, so they become null and the notice says where. JSON Lines reads one object per line; a broken line is reported with its number. YAML, TOML and XML are converted to JSON (XML attributes become keys starting with @, repeated elements become arrays), and the Convert tab writes YAML, TOML and XML back out.

The Transform tab runs JMESPath (the query language of the AWS CLI), JSON Query and jq on the document as you type, with example expressions for each. jq is the real jq 1.7 compiled to WebAssembly: it loads once (2.8 MB) the first time you choose it and then works offline. Use as input replaces the document with the result, so transforms can be chained.

Yes. The Table tab finds every array of objects in the document and shows the one you pick as a grid, with nested values as columns named by their path; double-click a cell to edit it. The Graph tab draws each object and array as a box linked to its parent; drag to move, scroll to zoom, and double-click a value to edit it. Either way the edit is written back into the document, and a number you type into a number keeps every digit.

Open the Compare tab, paste the other document and press Compare. Differences are listed by path as changed, added or removed; key order is ignored, and numbers are compared by value, so 1.0 equals 1 while 12345678901234567890 and 12345678901234567891 differ. Open in Diff Checker carries both documents to the Diff Checker's JSON / YAML structure mode, with array matching by key and exports.

Both, in the Schema tab. Sample document writes a document that satisfies the schema into the input, honouring types, required fields, enum, const, defaults and examples, formats such as email, UUID and date-time, ranges and lengths, $ref, allOf and oneOf. Visual editor shows the schema as a form where you rename properties, change types, mark them required, add descriptions, allowed values and formats, and add or remove properties; the JSON Schema updates as you go.

Files of 8 MB and more are parsed in a background worker, so the page never freezes, and are kept out of the text box. The formatted text and the tree draw only the lines on screen. In our tests a 62 MB file with 500,000 records opened in about 10 seconds, and JSONPath, Table and the other tabs worked on the whole document. The limit is your device's memory.

The Tree view renders the same parsed payload as a collapsible outline, letting you fold entire objects or arrays down to a single line and expand only the branches you need. This is especially useful for deeply nested API responses, where the plain formatted text can run to thousands of lines. Use Expand All or Collapse All to jump between a full overview and a fully drilled-in view. For documents with more than 60,000 values the tree is virtual: only the rows on screen are drawn, so a branch with 500,000 items opens instantly.

Changelog

  • v4.0.0 JSON5, JSONC and JSON Lines as explicit input formats, and YAML, TOML and XML converted in; TOML and XML added to Convert. Table view (any array of objects, editable) and Graph view (objects and arrays as linked boxes, values editable) that write edits back. Transform tab with JMESPath, JSON Query and jq (jq 1.7 in WebAssembly). Compare tab with differences by path and a hand-off to the Diff Checker's structure mode. Sample documents generated from a schema, and a visual schema editor. Every view now keeps long numbers exactly (tree, JSONPath, schema checks, types, CSV, SQL, YAML). Files of 8 MB and more open in a background worker with a virtual text view and tree, tested at 62 MB.
  • v3.1.0 History is off by default: with the Save to history switch on, only Beautify saves a run; typing never does. Beautify, Minify and Sort keys keep every number exactly as written (12345678901234567890, 1e400, -0) instead of rounding them; the warning names the views that still show the JavaScript value. CSV conversion has a Safe for Excel switch, on by default, that writes formula-like values (=, +, -, @) with a leading apostrophe, and keeps long numbers exact.
  • v3.0.0 Added Fix for almost-JSON with a list of changes made, full JSONPath (wildcards, recursive descent, slices, unions, filters) with every match and its path, JSON Schema validation and inference, type generation for TypeScript, Go, C#, Kotlin, Python, Java and Rust, SQL and CSV export with flattening, NDJSON detection and conversion, YAML output, string-literal escape and decode, a big-integer precision warning, indentation choice, file open, and share links.
  • v2.1.0 Added a path query box, a structure readout, an optional deep key sort, and syntax errors with line and column that move the caret to the offending character.
  • v1.4.0 Added a collapsible Tree view alongside the raw text output, with Expand All / Collapse All controls.
  • v1.3.0 Added a Download button next to Copy to Clipboard.
  • v1.2.0 Optimized syntax highlighting engine to prevent browser lock-ups when rendering heavily nested arrays over 5MB.
  • v1.0.0 Initial release of the secure client-side JSON processor.