A member name is not yet a path
Consider a JSON object whose key is draft/a~b and whose value is another object containing state. The slash belongs to the key; it does not create a nested level. A JSON Pointer, by contrast, identifies a value through slash-separated reference tokens. The pointer /orders/0/item could address an item inside an array, where 0 is an array index. Copying a raw member name into a pointer without escaping can therefore address the wrong place or fail completely.
RFC 6901 defines two escapes inside each token: a tilde becomes ~0 and a slash becomes ~1. The entire pointer also begins with a slash for each segment, while the empty pointer refers to the whole document. This notation concerns characters in a path, not the contents of the value being addressed. It does not change the JSON object itself. Use the token tool when you are assembling a path from a member name supplied by data or a user.
Build the example one segment at a time
For the key draft/a~b, first replace the tilde with ~0, then the slash with ~1. The escaped token is draft~1a~0b. Prefix a slash and append the separate member state to obtain /draft~1a~0b/state. The embedded converter below performs the token step; it intentionally does not add the leading slash because you may want to place the token anywhere in a longer pointer. Compare its output with the three stages in the diagram.
The inverse token tool replaces ~1 with slash before replacing ~0 with tilde. That order matters: decoding ~01 as ~1, then decoding it again as slash would change the original name. A pointer token is not URL percent encoding. If an application places a pointer inside a URL fragment, that outer URI layer has additional encoding rules. Keep the pointer syntax and the URL syntax separate when debugging a link or API request.
- Raw key: draft/a~b
- Escaped token: draft~1a~0b
- Full path: /draft~1a~0b/state
What flattening actually produces
The flatten tool walks a JSON object and writes leaf values under keys that look like complete JSON Pointers. For an object containing a state member beneath draft/a~b, one flat entry is /draft~1a~0b/state with the same leaf value. This can make nested data easier to compare, list or export. The reverse tool reads those path keys to rebuild a nested object, provided the paths do not collide or contradict each other. A flat entry is still a JSON object member, not an automatic lookup operation.
This particular tool treats arrays as leaf values; it does not make separate /0 and /1 entries for their elements. Empty objects are leaves too. A general JSON Pointer can address an array index, but a flat listing from this tool does not enumerate those indices. If one path assigns a scalar at /a while another tries to assign /a/b, the reverse operation must reject the conflict. Preserve the original JSON when changing path keys by hand.
A safe workflow for path-based data
Start with valid JSON and decide whether you need a single address or a complete flat view. For one address, split the intended route into actual member names, escape each name separately, and join the tokens with leading slashes. Do not escape the entire pointer in one pass: that would turn its separator slashes into part of a name. If you need to inspect many leaf values, flatten the object and review the generated keys before sharing them with another system.
When restoring data, check that every flat key begins with a slash and that its ~ escapes are valid. Watch for duplicate or conflicting assignments, arrays treated as leaves and literal keys that happen to contain dots or slashes. Test a round trip with a small object containing both punctuation characters, then compare the parsed JSON structures rather than indentation. The standards describe pointer syntax; the exact flattening policy is a feature of this local tool and should be checked before building a workflow around it.