Clean Messy JSON — normalize, trim, sort
Strip nulls, trim strings, sort keys, and standardize the shape of messy JSON in one click. Paste, run, copy clean output.
Paste your JSON → Get results instantly (no signup)
→ remove noisy values and remove nulls and empties.
1{2 "name": "Alice",3 "age": 304}Love the result?
Use this exact pipeline in your app, backend, or LLM workflow.
No setup needed. Works with curl, Node, Python.
Uses example data. For edited input, copy from the playground.
Works with:
- LLM outputs with stray whitespace and extra fields
- API responses with inconsistent casing or null fields
- Hand-edited config files
- Logs and event payloads
Example: input → output
About this tool
Input
{ "name": " Ada ", "email": "", "active": true, "debug": null }
Output
{ "name": "Ada", "active": true }
Clean JSON in one pass — strip nulls, trim whitespace, sort keys, and flatten the small inconsistencies that creep into hand-edited config, vendor-supplied API responses, and LLM-generated payloads. The output is the same shape as the input but stripped of low-value clutter, ready for downstream tooling that expects a predictable structure.
The most common reason to clean JSON is that the next step in the pipeline doesn't tolerate noise. Diff tools light up over whitespace differences. Schema validators fail on null values where a string was expected. CSV exports produce ragged columns when records have inconsistent extra keys. A cleanup pass at the boundary fixes all three at once.
This tool is destructive by default — null fields and empty strings are removed unless you opt out. Run it on a copy if you need an audit trail. The cleanup is idempotent: running it twice on the same input produces the same output, so it composes cleanly inside a pipeline.
How to clean messy JSON
- Paste your JSON document into the input panel.
- Pick which cleanup options to apply: drop nulls, trim strings, sort keys, dedupe arrays, normalize casing.
- Click Run. Copy the cleaned output, or pipe it into the next pipeline step.
When to use this tool
Use Clean JSON when a payload is valid but too noisy for the next workflow: webhook debugging, API response review, schema validation, JSON diff, CSV export, or ETL preprocessing. If the only task is deleting null fields, use Remove Null Values from JSON for the narrower workflow.
Common use cases
- Sanitize LLM-generated JSON before passing it to a parser. Pair with prepare JSON for an LLM prompt when the prep direction is reversed (input → completion).
- format an API response — strip the cruft out of webhook payloads, vendor SDK output, and sandbox-vs-production mismatches.
- format JSON online before validation, diffing, or conversion.
- Normalize hand-edited config files before committing them.
- Pre-process JSON before JSON to CSV to avoid ragged columns from records with inconsistent extra keys.
- Pre-process JSON before JSON Diff so the report focuses on real changes, not whitespace.
What this cleans
- Null fields — removed by default. Toggle off if your downstream consumer treats
nullas a meaningful value. - Empty strings — removed alongside nulls. Useful for forms where unfilled fields land as
"". - Whitespace inside strings — trimmed (leading/trailing). Internal whitespace is preserved.
- Key order — alphabetized so two cleaned documents are diff-stable.
- Duplicate array entries — collapsed when the strategy is set to "unique".
- Casing of keys — optionally normalized to camelCase, snake_case, or kebab-case.
Common errors when cleaning JSON
- Lossy null-strip. Some APIs (Stripe, Shopify) use
nullas a meaningful "explicitly cleared" signal. Don't strip nulls when downstream code distinguishes "missing" from "cleared". - Key-sort breaks ordered consumers. A handful of formats (some YAML conversions, ordered config files) depend on key order. Disable sorting when round-tripping through such consumers.
- Casing rename breaks references. If the JSON contains string values that name keys (paths, aliases, field references), renaming keys also requires renaming the references.
Why pipeline-based cleaning beats hand scripts
- Idempotent. Running the same cleanup twice produces the same output — safe to drop into any pipeline step.
- Composable. Combine with Extract Fields from JSON, Flatten JSON, or JSON to CSV without intermediate file shuffling.
- Reviewable. Each cleanup option is a checkbox, not a regex — easier to read in a code review than a one-liner.
- No uploads. Your JSON never leaves your device.
Related tools
Frequently asked questions
What does 'clean' mean for this tool?+−
Stripping nulls and empty strings, trimming whitespace inside string values, alphabetizing keys, and optionally normalizing casing or deduping arrays. Each option is independent — turn off the ones you don't want.
Is the cleanup idempotent?+−
Yes. Running the same options on the same input twice produces the same output, so the tool composes safely inside a pipeline.
Can I keep null fields?+−
Yes. Null-strip is on by default; turn it off when your downstream consumer treats `null` as meaningful (e.g. Stripe's API uses `null` for explicitly cleared fields).
Will it sort nested keys recursively?+−
Yes. The key-sort option walks the entire document depth-first, so every object — top-level and nested — has the same alphabetical order. Useful for diff stability.
Can I run this on a million-record array?+−
There is no hard size limit. Anything that fits in browser memory cleans without sending data anywhere. For multi-megabyte payloads, the cleanup runs in a Web Worker so it doesn't block the UI.
Common next steps
Related tools
Read more on the blog
Advanced usage (optional)
Clean Values
v1.0.0Description
Clean Values
Remove nulls, empty strings, empty collections, default values, and duplicates from JSON data. Optionally trim whitespace and sort keys. A comprehensive cleanup utility for normalizing messy data.
Operations
Each cleanup operation can be toggled independently. Enable multiple operations to clean data in a single pass.
Remove null values
Delete object keys that have null values at any depth.
Remove empty strings
Delete object keys that have empty string "" values.
Remove empty collections
Delete empty objects {} and empty arrays [].
Remove default values
Delete falsy defaults — 0 and false. Useful for stripping placeholder values.
Remove duplicates
Remove duplicate items in arrays. Compares both primitive values and full objects (deep equality).
Trim whitespace
Trim leading and trailing whitespace from all string values throughout the document.
Sort object keys
Sort object keys alphabetically at all levels.
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
| Apply to | path-picker | [] | Scope operations to specific paths only (empty = apply everywhere) |
| Remove null values | boolean | true | Remove object keys with null values |
| Remove empty strings | boolean | true | Remove object keys with empty string values |
| Trim whitespace | boolean | true | Trim leading/trailing whitespace from strings |
| Remove empty collections | boolean | false | Remove empty objects {} and arrays [] |
| Remove duplicates | boolean | false | Remove duplicate items in arrays |
| Remove default values | boolean | false | Remove falsy defaults (0, false) |
| Sort object keys | boolean | true | Sort object keys alphabetically |
Use Cases
API Response Cleanup
- Strip null fields from API responses before displaying
- Remove internal metadata fields (
__v,_id) with empty values - Trim whitespace from user-submitted form data
Data Normalization
- Deduplicate records imported from multiple sources
- Sort keys for consistent ordering across objects
- Remove placeholder defaults before exporting
Configuration
| Name | Type | Default | Description |
|---|---|---|---|
| Apply to | path-picker | [] | Scope operations to specific paths only (empty = apply everywhere) |
| Remove null values | boolean | true | Remove object keys that have null values |
| Remove empty strings | boolean | true | Remove object keys that have empty string values |
| Trim whitespace | boolean | true | Trim leading and trailing whitespace from all string values |
| Remove empty collections | boolean | false | Remove empty objects {} and empty arrays [] |
| Remove duplicates | boolean | false | Remove duplicate items in arrays (primitives and objects) |
| Remove default values | boolean | false | Remove falsy defaults (0, false) |
| Sort object keys | boolean | true | Sort object keys alphabetically |
Examples
Clean up this JSON and remove noisy values and remove nulls and empties.1{2 "name": "Alice",3 "age": 304}API Usage
curl -X POST https://your-domain.com/api/v1/utilities/cleanup.clean-json \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"inputs":{"primary":{"name":"Alice","bio":"","age":30,"address":null,"tags":[],"meta":{}}},"config":{"removeNulls":true,"removeEmptyStrings":true,"removeEmptyCollections":true,"removeDefaults":false,"removeDuplicates":false,"trimStrings":false,"sortKeys":false}}'1{2 "name": "Alice",3 "age": 304}