If this tool helped you, you can buy us a coffee ☕
将TOML格式配置文件转换为JSON,方便跨平台使用。
Enter TOML data to generate JSON.

JSON to XML & XML to JSON Converter
A two-way conversion tool for JSON and XML data structures, designed for development, testing, and data processing.

JSON to YAML & YAML to JSON Converter
Bidirectionally convert between JSON and YAML structured data formats, with support for custom output styling.

JSON to CSV & CSV to JSON Converter
Convert seamlessly between JSON arrays and CSV tabular data. Ideal for data analysis and software development.

JSON to C# Class Converter
Automatically convert JSON data into C# class definitions, ideal for .NET developers building data models.

JSON to XML & XML to JSON Converter
A two-way conversion tool for JSON and XML data structures, designed for development, testing, and data processing.

JSON to YAML & YAML to JSON Converter
Bidirectionally convert between JSON and YAML structured data formats, with support for custom output styling.

JSON to CSV & CSV to JSON Converter
Convert seamlessly between JSON arrays and CSV tabular data. Ideal for data analysis and software development.

JSON to C# Class Converter
Automatically convert JSON data into C# class definitions, ideal for .NET developers building data models.

JSON to Java POJO Generator
Automatically convert JSON strings into standard Java POJO class code for API integration, data modeling, and other development scenarios.
一个软件项目的配置文件用 TOML 格式(比如 config.toml)写好了,但部署系统只认 JSON,这时候就需要把 TOML 转成 JSON。TOML(Tom's Obvious, Minimal Language)是一种专门写配置的轻量格式,常见于 Rust 的 Cargo.toml、Python 的 pyproject.toml 中。JSON(JavaScript Object Notation)是几乎所有编程语言和 API 都支持的数据交换格式。在我们的在线转换工具里,你只需把 TOML 文本粘贴到左侧输入框,点击“转换”按钮,右侧就会输出 JSON。
主算例:一份标准的 TOML 配置:
[server]
host = "127.0.0.1"
port = 8080
[database]
name = "testdb"
user = "admin"
password = "secret"
[features]
enable_ssl = true
allow_guests = false在工具的“输入 TOML”框中粘贴以上内容,点击“转换”,右侧会显示:
{
"server": {
"host": "127.0.0.1",
"port": 8080
},
"database": {
"name": "testdb",
"user": "admin",
"password": "secret"
},
"features": {
"enable_ssl": true,
"allow_guests": false
}
}对照例:包含数组和日期时间的 TOML:
title = "Example"
numbers = [1, 2, 3]
created = 2023-08-15T10:00:00Z转换后 JSON 中,日期变成了字符串:
{
"title": "Example",
"numbers": [1, 2, 3],
"created": "2023-08-15T10:00:00Z"
}注意 TOML 的数组原样保留,但日期被转成 ISO 8601 字符串(JSON 本身没有日期类型)。
转换成功后的 JSON 可以直接复制使用。你需要关注几个差异:
a.b.c)会变成嵌套的 JSON 对象。[[items]])在 JSON 中变成对象数组,顺序与原 TOML 中出现顺序一致。# 注释在 JSON 中不存在,转换后会被全部丢弃。如果输入 TOML 有语法错误(如重复键、缩进不对),工具会显示错误提示,不会输出 JSON。
say = "他问:"你好"" 应该写成 say = "他问:\"你好\""。5 是整数,5.0 是浮点数;JSON 会如实区分,不能混用。[[items]] 在文件头和文件尾重复),TOML 规范会合并它们,导致 JSON 数组顺序与预期不符。2023-08-15T10:00:00Z),如果写成 08/15/2023 会被当作普通字符串。toml2json)。现在你可以在上方计算器里试试自己的 TOML 文件。