All Tools
Categories
XML Tools 64 Email Marketing Tools 55 Import-Export Tools 50 JSON Tools 36 Text Tools 12 Shipping Freight Tools 5 Calculator 4 Marketing Tools 3
About Contact Privacy

Flatten JSON Object

Flatten a nested JSON object into a single-level object with dot- or underscore-separated keys. Choose separator, array handling, sort order and table preview. No uploads.

Nested JSON Input
Waiting for input
Flat Object
Each flat key encodes its full path — settings.limits.max_items tells you where the value lived. Underscore separators produce env-var-style names for config tooling.

About Flatten JSON Object

Nested JSON is elegant for humans and a problem for every flat consumer downstream: environment variables, feature-flag systems, simple key-value stores and spreadsheet exports all want one level. When the configuration lives four levels deep, someone has to walk it and hand-write the flattened form — a slow, error-prone mapping that must be redone every time the structure changes.

Flatten JSON Object turns any nested object into a single level with zero effort. Every path becomes one key — settings.limits.max_items with a dot separator, settings_limits_max_items with an underscore — so the key itself carries the full history of where the value lived. Arrays flatten with indices or collapse to JSON strings, whichever your consumer prefers. Omit nulls and empties for clean config, or include them for complete data coverage, sort alphabetically or keep encounter order, and verify the result in a two-column table preview. All client-side, nothing uploaded.

Features

  • Dot or underscore separators: Choose the key style your consumer expects — dotted paths or env-var-style underscores.
  • Two array strategies: Flatten arrays with indices (items.0.name) or keep them as JSON-string values.
  • Empty-value control: Omit nulls, empty objects and empty arrays, or include every branch explicitly.
  • Sort keys alphabetically: For diff-friendly, deterministic output, or keep document encounter order.
  • Table preview: Verify the result as a path/value table before shipping it.
  • Pretty or compact output: Match the style to the consumer.
  • Live conversion: The flat object updates as you type or change options.
  • Copy and download: Export the flat object or the table in one click.
  • Private: Everything runs in your browser; nothing is uploaded.

How to Use

  1. Paste your nested JSON object into the input pane.
  2. Choose the separator — dot for readable paths, underscore for env-var style keys.
  3. Pick the array strategy — indexed paths for data, JSON strings for config.
  4. Set empty-value and sorting options to match your consumer.
  5. Verify in the table preview, then copy or download the flat object.

Examples

Example 1 — Config to environment variables. A twelve-factor app needs every config value as an env var. The nested config flattens with underscore separators into APP_SETTINGS_LIMITS_MAX_ITEMS=50 — names the deployment team can read at a glance and wire into the platform in minutes.

Example 2 — Feature flags. A flag service accepts flat JSON. The nested flags object flattens with dot separators: notifications.email.enabled, notifications.push.enabled — each flag becomes one key the service can evaluate without a path walker.

Example 3 — Comparing configs across environments. Dev, staging and prod configs flatten, sort, and diff in one pass. The dotted keys make the differences read as exact locations: staging.retries=1 vs prod.retries=3.

Example 4 — Database column mapping. An export job needs one column per field. Indexed array mode yields order.items.0.sku as a real column key, and include-empty guarantees the schema is complete even when values are absent.

Benefits

  • Every consumer gets a flat structure: Env vars, flag services, spreadsheets and KV stores accept the output directly.
  • Self-describing keys: Each key encodes its full path — no lookup table needed.
  • Diff-friendly and deterministic: Sorted flat output compares cleanly between environments and versions.
  • No hand-written mappings: The flattening updates itself whenever the source structure changes.
  • Safe and instant: Client-side processing with a live preview and zero uploads.

Frequently Asked Questions

Why flatten a nested JSON object?
Because the consumers in your stack do not do nested: environment variables are flat key-value pairs, feature flags are flat, many databases want one column per field, and config comparison tools need a canonical form. Flattening maps the nested structure onto a single level where every path becomes one key.
How are keys constructed?
Every level of nesting is joined with the chosen separator. With the default dot separator, settings.limits.max_items becomes the key settings.limits.max_items. With the underscore separator it becomes settings_limits_max_items — the shape used by environment-variable style configs. The key tells you the entire path at a glance.
What happens to arrays?
You choose. Indexed mode flattens arrays into paths with indices — items.0.name, items.1.name — preserving every position. JSON-string mode keeps the array as a single value serialized as JSON, which is compact but opaque. Indexed is better for data, string mode for config where the array is just a value.
Are nulls and empty structures kept?
Only if you enable include-empty. By default nulls, empty objects and empty arrays are omitted, which keeps the flat output clean for config use. When the absence of a key is meaningful — for example in data migrations — switch the option on and every branch appears.
What is the table preview for?
The flat result is easiest to verify as a two-column table: path on the left, value on the right. It doubles as a human-readable inventory of the document, useful before you ship the flattened version somewhere.
Is my JSON uploaded anywhere?
No. Flattening and the table preview are generated entirely in your browser. Nothing is uploaded, stored or logged.