TBToolbox
Developer Tools

JSON Flattener

JSON Flattener walks non-array objects and joins nested property names with dots. Arrays, primitives, and null are stored as leaf values. Keys already containing dots become ambiguous, empty objects emit no entry, and a top-level primitive uses an empty-string key. The transform records no escaping or type metadata, so it is not reliably reversible for every valid JSON value.

Runs locally — files stay on your device
Quick answer

Are arrays expanded into numeric paths?

No. Each array remains a complete leaf value.

Dot notation needs an escaping convention

Flattening maps a tree to paths. Without escaping, a literal key a.b cannot be distinguished from nested keys a then b.

How it works

Every non-array object is traversed recursively; path segments concatenate with periods; other values are assigned to the accumulated path.

Key concepts

Arrays are leaves

Their internal elements are not flattened.

Empty objects disappear

They have no leaf assignment.

When to use it

  • Inspect ordinary nested objects with dot-free keys.
  • Prepare simple configuration mappings.
  • Compare leaf values at readable paths.

When not to use it

  • Do not expect perfect round trips with dotted keys.
  • Do not expect array index paths.
  • Do not use it where empty-object preservation matters.

Worked examples

Nested

Input
{"user":{"name":"Ana"}}
Expected output
{"user.name":"Ana"}

One dot path is created.

Array

Input
{"x":[1,2]}
Expected output
{"x":[1,2]}

Array stays intact.

Dotted key

Input
{"a.b":1}
Expected output
{"a.b":1}

It is indistinguishable from nested a.b.

Common mistakes

Assuming reversibility

Dots and empty objects lose structure. Correction: Use an escaped path standard.

Expecting array indices

Arrays are terminal. Correction: Use a JSON Pointer flattener.

Ignoring empty objects

They vanish. Correction: Represent them explicitly if needed.

Best practices

  • Use only with known dot-free keys.
  • Test flatten/unflatten on representative data.
  • Keep the original document.

Related operations and differences

CSV to JSON

Choose CSV to JSON when you need to convert a header-based CSV table to JSON.; use JSON Flattener specifically for json flatten.

Extract JSON Values

Choose Extract JSON Values when you need to list every primitive value in a JSON document.; use JSON Flattener specifically for json flatten.

JSON Beautifier

Choose JSON Beautifier when you need to format JSON with readable indentation.; use JSON Flattener specifically for json flatten.

JSON Key Sorter

Choose JSON Key Sorter when you need to sort object keys recursively.; use JSON Flattener specifically for json flatten.

JSON Minifier

Choose JSON Minifier when you need to remove unnecessary JSON whitespace.; use JSON Flattener specifically for json flatten.

JSON String Escape

Choose JSON String Escape when you need to escape text for a JSON string value.; use JSON Flattener specifically for json flatten.

Limitations and privacy

  • Objects only are traversed; arrays are leaves.
  • No dot escaping, JSON Pointer, empty-object retention, circular handling, schema, or guaranteed inverse.

Input is processed locally in this browser and is not uploaded by the tool.

Frequently asked questions

Are arrays flattened?

No.

What happens to empty objects?

They produce no leaf entry.

Can keys contain dots safely?

No.

Is the original modified?

No.