# JSON to key-path text: the path = value format and its ambiguities

> How nested JSON is flattened to one 'path = value' line per leaf, how arrays and empty containers appear, and the cases where different documents give the same lines.

- Tool: [JSON to plain text Converter](https://toolsg.com/en/json-to-text)
- Language: en (available: en, zh, ms, ta)
- Last verified against official sources: 2026-10-19
- Source site: ToolSG — a planning guide, not official or financial advice. Cite the agencies listed under Sources.

## Key figures at a glance

| Fact | Value | Source |
| --- | --- | --- |
| Line format | path = value, one line per leaf — Object keys are joined with a dot; array positions are written [0], [1] … |  |
| Empty containers | Written as [] or {} — Other lines are only written for leaf values, so empty arrays and objects get their own line. |  |
| Strings | Written without quotes — So the string "null" and the value null look identical. |  |
| Download | converted.txt — Plain text containing exactly what the output box shows. |  |

## What the tool produces

Paste JSON and the right-hand box lists every leaf value (string, number, boolean or null) on its own line as `path = value`. The path is built from the keys above it: object keys are joined with `.`, and array items are written as `[index]` with a zero-based index and no dot before the bracket. The conversion runs in your browser and updates as you type; a Download link (`converted.txt`) appears once there is output.

Example input: `{"user":{"name":"Mei","langs":["en","zh"],"address":{"city":"SG","unit":null},"empty":[],"none":{}},"ok":true,"n":1.50,"s":"null"}`

```
user.name = Mei
user.langs[0] = en
user.langs[1] = zh
user.address.city = SG
user.address.unit = null
user.empty = []
user.none = {}
ok = true
n = 1.5
s = null
```

The same text also shows the limits of the format: `1.50` printed as `1.5`, and the string `"null"` (last line) looks exactly like the real `null` on the `unit` line.

## Array roots and scalar roots

An array at the top level starts each path with the index: `[{"name":"Mei","age":30},{"name":"Ali","age":25}]` becomes `[0].name = Mei`, `[0].age = 30`, `[1].name = Ali`, `[1].age = 25`. Nested arrays chain indexes: `[[1,2],[3]]` gives `[0][0] = 1`, `[0][1] = 2`, `[1][0] = 3`. A bare scalar such as `5` or `"hi"` becomes `value = 5` and `value = hi`. A top-level `[]` or `{}` is written as ` = []` or ` = {}` with a leading space, because the path is empty.

## Where the output is ambiguous

The format is meant for reading, grepping and diffing, not for converting back to JSON. Different documents can produce identical lines:

| Input | Output | Problem |
| --- | --- | --- |
| `{"a.b":1}` and `{"a":{"b":1}}` | both `a.b = 1` | Dots inside keys are not escaped |
| `{"a[0]":1}` and `{"a":[1]}` | both `a[0] = 1` | Brackets inside keys are not escaped |
| `"null"` and `null` | both `= null` | Strings carry no quotes |
| `"true"` and `true`, `"5"` and `5` | identical | Same reason |
| `{"a":"x = y"}` | `a = x = y` | The first ` = ` is the separator; later ones are part of the value |
| `{"a":"line1\nline2"}` | two physical lines | A newline inside a string breaks the one-line-per-leaf rule |
| `{"":1}` | `value = 1` | An empty key leaves an empty path, shown as `value` |
| `{"a":{"":2}}` | `a. = 2` | Empty key after a dot |

Leading and trailing spaces in a string are kept as they are, so `"  pad  "` prints `a =   pad  ` and the spaces are easy to miss.

## Numbers and order

Values pass through `JSON.parse`, so numbers are JavaScript doubles: `12345678901234567890` prints as `12345678901234567000`, `-0` as `0`, and `1e400` as `Infinity`. Keys that look like integers come out first and in ascending order; other keys keep their source order. Duplicate keys keep only the last value.

> **Tip:** To find where a value lives in a big response, convert it here and search the output for the value. Each hit already carries the full path, which you can then apply with the [JSON viewer](https://toolsg.com/en/json-viewer).

## Common mistakes

- Expecting a reversible format. If you need to rebuild JSON from the lines, use a delimiter that cannot occur in keys, or keep the original document.
- Reading a quote-free `null` as the JSON null when the value may be the text "null".
- Treating the paths as JSONPath. JSONPath (RFC 9535) starts with `$`, quotes unusual keys and has a different escaping scheme.
- Feeding JSON Lines (several documents) in one go; the parser accepts only one JSON text and reports an error.

## Related tools

Explore the structure visually with the [JSON viewer](https://toolsg.com/en/json-viewer), flatten arrays of records into a table with [JSON to CSV](https://toolsg.com/en/json-to-csv) or [JSON to TSV](https://toolsg.com/en/json-to-tsv), and compare two flattened outputs with the [text diff](https://toolsg.com/en/text-diff).

## Frequently asked questions

**Is my data uploaded anywhere?**

No. The conversion runs entirely in your browser using JavaScript. Nothing you paste leaves your device, is logged, or is stored on a server.

**How large a document can it handle?**

The limit is your browser's memory rather than any server quota. Documents of a few megabytes convert without trouble; very large files may make the page briefly unresponsive while it works.

**What happens to nested data?**

Formats that have no concept of nesting store nested values as a JSON string inside the cell, so nothing is silently discarded and the structure can be recovered.

**Does it handle quotes and commas inside fields?**

Yes. Parsing follows RFC 4180, so quoted fields containing commas, escaped double quotes, and line breaks inside a field are all read and written correctly.


## Sources

- [IETF — RFC 8259, The JSON Data Interchange Format](https://www.rfc-editor.org/rfc/rfc8259.html) — The value types being flattened.
- [IETF — RFC 9535, JSONPath](https://www.rfc-editor.org/rfc/rfc9535.html) — A standard path syntax (for example $.user.langs[0]); this tool's paths are similar but not JSONPath.
