JSON flatten and unflatten
Flattening is how JSON gets into a spreadsheet, a form post, a config file or a database column, and unflattening is how it gets back out. Paste a document to go one way, paste dotted keys to go the other, and export the result as CSV or as environment lines.
The two directions here are exact inverses, which sounds obvious and usually is not. Most implementations quietly drop empty objects and empty arrays, because there is no leaf inside them to write down — and that missing field turns up as a bug three systems downstream. An empty container is a fact about the document, so it is written out as itself and comes back as itself.
The one thing that cannot be made safe is a key with the separator already inside it: {"a.b": 1} and {"a": {"b": 1}} flatten to exactly the same thing, and no amount of cleverness can tell them apart afterwards. Rather than pick a winner silently, those keys are listed so you can choose a different separator — slashes and double underscores both work.
Questions
Can I get the original document back?
Yes, that is the point. Flatten, then unflatten, and you have exactly what you started with — including empty objects, empty arrays, nulls and false, all of which are easy to lose on the way through.
Should array indices be in brackets or dots?
Brackets, a.b[0], read better and are what JSONPath uses. Dots, a.b.0, are what most form encoders and environment files expect. The trade-off with dots is that a numeric key can no longer be told from a position.
What happens to a key that contains a dot?
It is reported as a collision rather than guessed at, because after flattening there is genuinely no way to tell it from a nested key. Change the separator to something that does not appear in your keys and the ambiguity goes away.
How does the CSV handle records with different fields?
Every key any record has becomes a column, in the order the keys were first seen, and a record missing one gets an empty cell. Values containing commas, quotes or newlines are quoted properly, so the file opens correctly in a spreadsheet.
Is anything uploaded?
No. All of it happens in this tab, which matters because the JSON people want as a spreadsheet is usually an export with real records in it.