JSON Sort — Sort JSON Keys and Arrays Online
Normalize key order and sort arrays for stable diffs, canonical fixtures, and readable configs. Choose alphabetical, natural, or numeric order. All processing stays in your browser.
Developer notes
Sorting runs automatically as you type, paste, upload, load a sample, or change options (short debounce on input; option changes debounced ~250 ms). Sorting parses JSON first — fix syntax errors or use JSON repair. Default scope is `both`; choose `objectsOnly` when you only need key canonicalization for git diffs (array options reset to Preserve order). Natural sort orders `item2` before `item10`. Array `byObjectKey` requires a field name; objects missing the field sort last. Mixed-type arrays sort by typeof order, then value — see unit tests for the exact order. `maxDepth` skips sorting at and below the limit for each branch. Options are not saved between sessions (aligned with other JSON tools). For byte reduction after sorting, use JSON minifier.
JSON sort options
- Scope
- Sort object keys only, array elements only, or both. Default is `both`; use `objectsOnly` for classic key canonicalization (array order unchanged when array mode is Preserve).
- Key mode
- Alphabetical (lexicographic), natural, or numeric key ordering. Natural puts `item2` before `item10`.
- Direction
- Sort keys and array elements in ascending (A→Z) or descending order.
- Case sensitive keys
- When off, `Apple` and `apple` sort together, ignoring case. This applies to keys only, not string values.
- Array sort mode
- Preserve input order, sort primitives by value, or sort objects by a field name.
- Array object key
- Field used when sorting arrays of objects. Objects missing the field sort last.
- Primitive array sort
- Alphabetical, natural, or numeric ordering for primitive array elements.
- Max depth
- Limit sorting to the top N levels. Nested subtrees at the limit stay untouched.
- Indent size
- Spaces per indentation level in the formatted output.
- Indent style
- Spaces or tabs for output formatting.
When teams pick this route
Normalize API snapshots before JSON Diff in CI. Canonicalize OpenAPI/JSON Schema examples for review. Sort user lists by `name` or `id` for display fixtures. Prepare stable golden files for Jest snapshot tests.
Worked examples
Canonical keys for diff
Before
After
Sort array of objects by name
Before
After
Navigate related JSON tools
Browse the JSON tools hub. Compare sorted output in JSON diff and prettify without reordering in the JSON formatter. Validate with the JSON validator or explore structure in the JSON tree viewer.
JSON sort FAQ
Ordering, arrays, and privacy
How is this different from the JSON formatter?
The formatter adds indentation and optional basic key sorting. JSON Sort is dedicated to reordering keys and arrays with full control over mode, direction, depth, and array behavior.
Does sorting change values?
No. Only the order of object keys and array elements changes. Scalar values and nested content stay the same.
Is array order preserved by default?
Array elements keep their input order while Array sort mode is Preserve order (the default). Reorder arrays by switching to By value or By object key, or set scope to Arrays only / Objects and arrays with a non-preserve array mode.
Do I need to click a Sort button?
No. Sorted output updates automatically as you edit JSON or change options (with a short debounce while typing).
Natural vs alphabetical sort?
Natural sort treats embedded numbers correctly, so `item2` sorts before `item10`. Alphabetical uses plain lexicographic order.
When should I use max depth?
Use `maxDepth: 1` to sort only top-level keys and leave nested objects exactly as pasted. This is useful for partial normalization.
Is my JSON uploaded to a server?
No. Parsing, sorting, and formatting run entirely in your browser.
JSON Tools
Validate, format, repair, compare and explore JSON in your browser, alongside the JSON minifier and converters.
Explore other tool categories
- Minify
Minify JavaScript, CSS, HTML, JSON, XML, SVG and other formats to cut the bytes you ship, before gzip or a CDN.
- Unminify
Make minified code readable again to debug or review it. Unminify JavaScript, CSS, TypeScript, SCSS, LESS, SQL, YAML and other formats.
- Conversion
Convert data between JSON, YAML, XML, CSV, TOML and other formats locally, with no upload to a server.
- Encoding
Encode or decode Base64, URLs, HTML entities and JWTs, and generate hashes and HMACs in your browser.
- Serialization
Serialize and deserialize PHP data structures beside JSON workflows.
- SVG Tools
Preview, optimize with SVGO, export as a data URI, resize, beautify, convert to JSX and validate SVG in your browser.
- Beautify
Make code readable with consistent indentation. Beautify JavaScript, CSS, TypeScript, SCSS, LESS, Markdown, GraphQL, SQL, YAML and more in your browser.
- CSS preprocessors
Compile SCSS or LESS to standard CSS in your browser. Pair it with beautify or minify to handle a whole stylesheet.
- Color & CSS Tools
Check WCAG contrast, convert CSS colors and units, and generate shades, border-radius and box-shadow code in your browser.
- DevOps & Infra
Terraform HCL format/validate/minify, Dockerfile format & lint, Docker Compose and .env validation.
- CI/CD
Format GitHub Actions and GitLab CI YAML and check the structure of workflows and jobs in your browser.
- Logs & observability
Format, filter and validate JSON and NDJSON logs, and turn Nginx or Apache access logs into CSV or TSV.
- Kubernetes
Multi-doc manifests, structural validate, Ingress/Deployment starters, and Helm values formatting.
- Networking / IP
Subnet calculator, IP converter, range to CIDR, CIDR summarize and IP-in-subnet checks for IPv4 and IPv6, in your browser.
- Security & tokens
Inspect JWKS, verify JWTs, decode X.509 certificates, convert PEM and JWK, scan text for secrets and hash with bcrypt in your browser.
- API & schemas
Format, validate, lint and convert OpenAPI, JSON Schema and GraphQL SDL in your browser.
- HTTP Tools
Paste cURL commands, HTTP messages, URLs, HAR files and Cookie or Set-Cookie headers to format and inspect them. Nothing is sent.
- SEO / Web Tools
Generate meta tags, Open Graph, Twitter Card, robots.txt, sitemap.xml and JSON-LD in your browser. Previews come from your input, and your site is never fetched.
- Developer utilities
Timestamps, UUID, ULID, Nanoid, cron, passwords, regex, slugs, number bases, letter case, text diff, chmod and Lorem Ipsum, all in your browser.
- Text & Markdown
Count words, build Markdown tables of contents, turn CSV into Markdown tables and sort or deduplicate lines in your browser.
- AI & LLM
Count tokens, estimate API costs, check context-window fit, convert JSON to TOON and analyze prompts, all in your browser.
- Test Data
Dummy names, emails, phone numbers, addresses, dates, IBANs, card numbers and JSON, CSV or SQL rows for fixtures and database seeds. Everything is generated in your browser.
- Barcode labels
Draw Code 128, EAN-13 and UPC-A labels and static QR codes in your browser, then download PNG or SVG. This is not a GS1 lookup.