Example
Input (JS object literal)
{
// comments OK
id: 1,
name: 'Alice',
active: true,
tags: ['admin', 'user',],
}Output (standard JSON)
{
"id": 1,
"name": "Alice",
"active": true,
"tags": [
"admin",
"user"
]
}Note
Four-step transform — strip comments, single → double quotes, add quotes around bare keys, strip trailing commas. No `eval` / `new Function` — safe.
Usage / FAQ
When to use
- Convert an object literal copied from JS code into API-ready JSON
- Clean up JSON5 / JSONC config files into strict JSON
- Turn `console.log` debug output into pasteable JSON
- Prepare input for Postman / Insomnia and similar API tools
- Tidy 'loose JSON' with comments / trailing commas
FAQ
- Q.Does this use `eval`?
- A.Never — for security reasons. A custom token scanner strips comments, swaps quote styles, adds key quotes, removes trailing commas, then validates with `JSON.parse`.
- Q.What about function values or regex literals?
- A.Unsupported — JSON has no such concept, so parsing errors out. Remove functions, regexes, or `undefined` from the input first.
- Q.How is this different from JSON5?
- A.JSON5 formalizes unquoted keys, trailing commas, etc. as a superset. This tool accepts JSON5-compatible input and emits strict JSON — no JSON5 library dependency, just a self-contained transformer.
Fun facts
JSON was defined by Douglas Crockford in 2001 — born from web APIs needing something lighter than XML for data interchange. The 2013 ECMA-404 spec is short enough to fit on a single page.
JSON.orgJSON is a *strict* subset of JavaScript object literals — keys must be double-quoted, trailing commas are forbidden, comments aren't allowed, function values aren't allowed. The two most common gotchas when copying JS objects into JSON: trailing commas and unquoted keys.
RFC 8259 — JSONJSON5 (Aseem Kishore, 2012) is the ergonomic cousin — comments, trailing commas, single quotes, and unquoted keys are all allowed. It's not a standard, but it's familiar from VS Code's `settings.json` and patterns in npm's `package.json`.
JSON5
Related tools
- JSON Formatter / Validator
Format, validate, and minify JSON strings. Adjust indent and optionally sort keys. Runs entirely in your browser.
- String Case Converter
Convert strings between camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, and Title Case — all six cases shown side-by-side.
- Regex Tester
Test JavaScript regular expressions with live match results. Supports g/i/m/s/u/y flags and capture groups.
- Markdown Preview
Render Markdown to HTML side-by-side. Supports CommonMark + GFM (tables, fenced code, task lists). marked is lazy-loaded.
- HTML → Markdown
Convert HTML into Markdown. Headings, lists, links, code, tables, blockquotes. Uses the browser's DOMParser — accurate, 0 dependency.
- YAML ↔ JSON
Convert between YAML and JSON. Tolerates comments and multiline strings on the YAML side. yaml is lazy-loaded.
- Text Diff
Compare two texts and highlight added/removed lines, words, or characters.
- JSON Diff
Compare two JSON values, with optional key sorting and JSON-aware error messages.
- CSV ↔ JSON
Convert between CSV and JSON. Handles quoted fields, custom delimiters, and header rows.
- SQL Formatter
Format SQL queries with proper indentation and keyword casing. Supports PostgreSQL, MySQL, SQLite, and standard dialects.
- XML Formatter
Pretty-print or minify XML with attribute preservation. Handles SOAP, sitemaps, and config files.
- XML ↔ JSON
Convert between XML and JSON with attribute and element handling.
- Smart Paste
Paste any text and get tool recommendations — JSON, JWT, Base64, URL, UUID, Cron, and 9 more types auto-detected.
- Lorem Ipsum
Generate placeholder text in words, sentences, or paragraphs. Classic Lorem Ipsum or randomized.
- JSON Path
Query JSON with JSONPath expressions ($.store.book[*].author etc.) and inspect matches.
- JSON Schema Validator
Validate JSON data against a JSON Schema (Draft 2020-12). Powered by Ajv with format support.
- JSON Schema Generator
Generate a JSON Schema (Draft 2020-12) from a sample JSON. Infer types, required fields, and nested structures automatically.
- HTML Formatter
Beautify or minify HTML with proper indentation, attribute alignment, and configurable wrap.
- CSS Formatter
Beautify or minify CSS with proper indentation. Configurable selector and property style.
- JavaScript Formatter
Beautify or minify JavaScript with brace style and indent options. Powered by js-beautify.
- TOML ↔ JSON
Convert between TOML (Tom's Obvious Minimal Language) and JSON. Used in Cargo.toml, pyproject.toml, etc.
- INI ↔ JSON
Convert INI configuration to JSON and back. Supports sections, comments (; or #), and key=value.
- JSON → TypeScript
Generate TypeScript interfaces from a JSON sample. Nested objects become separate interfaces.
- Slug Generator
Convert text into a URL-safe slug. Configurable separator, lowercase, and accent stripping.
- ASCII Tree
Convert indented text or path list into a box-drawing tree (├── │ └──).
- Diff Patch
Generate a unified diff (-u) patch from two text inputs. Compatible with `git apply` / `patch -p0`.
- Mock Data
Generate fake JSON records — names, emails, UUIDs, dates, and more. 0 dependency.
- MongoDB Extended JSON
Convert MongoDB Extended JSON (EJSON) between Canonical and Relaxed forms, or strip BSON wrappers to plain JSON. Recognizes 16 wrapper types ($oid/$date/$numberLong/$numberDecimal/$binary/...).