JSON数据扁平化
把嵌套结构摊平成 a.b.c 形式的单层键值。
关于「JSON数据扁平化」
它属于「JSON 工具」分类:JSON 的格式化、结构变换与各种数据格式互转。
- 把多层嵌套的对象摊平成单层键值对,键名用路径表示,例如
user.address.city。 - 数组默认展开为
tags[0]形式;取消勾选后会变成tags.0。 - 分隔符可自定义,当键名本身含有点号时,改用
/或__可避免歧义。 - 空对象与空数组会作为叶子节点保留,反扁平化时可以完整还原。
- 常用于国际化词条、配置项对照表,以及把嵌套数据导入到扁平的表格里。
完全免费、无需注册;所有处理都在浏览器本地完成,文件不会上传到任何服务器。
相关关键词:JSON数据扁平化、JSON 工具、扁平化、flatten、在线工具、免费
如何使用「JSON数据扁平化」
- 打开工具:打开「JSON数据扁平化」页面,无需注册、无需安装任何软件。
- 准备输入:粘贴嵌套 JSON,摊平成 a.b.c 形式的单层键值,便于表格化处理。
- 填入内容:把内容粘贴进输入框,或把文件拖入页面;也可以点击「示例」先填入样例数据试一下。
- 设置选项并处理:按需调整页面上的选项,然后点击处理 / 转换 / 生成按钮。
- 获取结果:处理完全在浏览器本地完成,结果可直接复制或下载,文件不会上传到任何服务器。
常见问题
- 扁平化有什么用?
- 很多场景只接受单层结构,比如 i18n 语言包、环境变量、表格的列。把嵌套 JSON 摊平后,就能直接对照和检索每一个字段的完整路径。
- 可以还原回去吗?
- 可以,使用配套的「JSON数据反扁平化」工具,用相同的分隔符设置即可还原成原来的嵌套结构。
- 键名里本来就有点号怎么办?
- 这种情况下用默认的点号分隔会产生歧义,建议把分隔符改成
/、|或__等不会出现在键名中的字符。
Flatten JSON
Flatten nested structures into a.b.c single-level keys.
About Flatten JSON
Belongs to “JSON Tools”: Format, transform and convert JSON to and from various data formats.
- Collapses deeply nested objects into flat key-value pairs with path-based keys like
user.address.city. - Arrays expand as
tags[0]by default; uncheck to usetags.0instead. - The separator is customizable; if a key already contains a dot, switch to
/or__to avoid ambiguity. - Empty objects and arrays are kept as leaf nodes, so you can fully restore them via unflatten.
- Handy for i18n bundles, config tables, and importing nested data into flat spreadsheets.
Free, no sign-up; everything runs locally in your browser and files are never uploaded.
Keywords: Flatten JSON, JSON Tools, flatten, flatten nested, online tool, free
How to use Flatten JSON
- Open the tool:Open the “Flatten JSON” page — no sign-up and nothing to install.
- Prepare the input:Paste nested JSON to flatten it into single-level keys like a.b.c for tabular handling.
- Provide the input:Paste your content into the input box or drop a file onto the page; you can also click “Sample” to try example data first.
- Adjust options and run:Adjust the options if needed, then click the process / convert / generate button.
- Get the result:Everything runs locally in your browser; copy or download the result — your files are never uploaded.
FAQ
- What is flattening for?
- Many systems accept only flat structures — i18n bundles, env vars, spreadsheet columns. Flattening lets you compare and look up every field by its full path.
- Can it be reversed?
- Yes — use the companion “JSON unflatten” tool with the same separator to restore the original nested structure.
- What if a key already has a dot?
- A default dot separator is then ambiguous; change it to a character not present in keys, such as
/,|or__.