Convert TOML to CSV
Max file size 100mb.
TOML vs CSV Format Comparison
| Aspect | TOML (Source Format) | CSV (Target Format) |
|---|---|---|
| Format Overview |
TOML
Tom's Obvious Minimal Language
A minimal, human-readable configuration file format created by Tom Preston-Werner. Features hierarchical sections, typed values, and a strict formal grammar. Designed to be unambiguous and easy to map to hash tables. Native config format for Rust and Python build systems. Configuration Format Hierarchical Data |
CSV
Comma-Separated Values
A plain text format for tabular data where each line represents a row and fields are separated by commas. One of the oldest and most widely supported data exchange formats. Compatible with virtually every spreadsheet application, database system, and programming language. Tabular Data Universal Format |
| Technical Specifications |
Structure: Key-value pairs with [sections]
Encoding: UTF-8 required Data Types: Strings, integers, floats, booleans, dates, arrays, tables Nesting: [section.subsection] and [[array_of_tables]] Extensions: .toml |
Structure: Rows of comma-delimited fields
Encoding: ASCII/UTF-8 (RFC 4180) Delimiter: Comma (or semicolon, tab) Quoting: Double quotes for fields with commas Extensions: .csv |
| Syntax Examples |
TOML with sections and arrays: [package] name = "myapp" version = "1.0.0" edition = "2021" [dependencies] serde = "1.0" tokio = "1.28" axum = "0.6" |
CSV tabular output: section,key,value package,name,myapp package,version,1.0.0 package,edition,2021 dependencies,serde,1.0 dependencies,tokio,1.28 dependencies,axum,0.6 |
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Created: 2013 by Tom Preston-Werner
Current Version: TOML v1.0.0 (2021) Status: Stable, formally specified Evolution: Active community development |
Origin: 1972 (IBM mainframes)
RFC 4180: 2005 (formal specification) Status: Universal standard Evolution: Stable, minimal changes |
| Software Support |
Rust/Cargo: Native support
Python: tomllib (3.11+), tomli JavaScript: @iarna/toml, smol-toml Other: Go, Java, C#, Ruby libraries |
Spreadsheets: Excel, Google Sheets, Numbers
Databases: MySQL, PostgreSQL, SQLite Python: csv module, pandas Other: Every language and platform |
Why Convert TOML to CSV?
Converting TOML configuration files to CSV format unlocks the ability to analyze, compare, and visualize configuration data using spreadsheet tools. TOML's hierarchical key-value structure is flattened into a tabular format that can be opened directly in Microsoft Excel, Google Sheets, or Apple Numbers for sorting, filtering, and charting.
This conversion is particularly valuable for DevOps teams that need to audit or compare configurations across multiple environments. By converting Cargo.toml, pyproject.toml, or application configuration files to CSV, you can create a spreadsheet that lists all settings with their sections, keys, and values. This tabular view makes it easy to spot differences, identify missing settings, or create configuration documentation spreadsheets.
CSV format is also ideal for importing configuration data into databases or data analysis tools. When you need to track configuration changes over time, store settings in a relational database, or feed configuration data into reporting systems, CSV provides the universal bridge between TOML's structured format and tabular data systems. Tools like pandas, R, and SQL databases can all ingest CSV directly.
The conversion process maps TOML's hierarchical structure into flat CSV rows. Each key-value pair becomes a row with columns for the section path, key name, value, and optionally the data type. Arrays and tables of arrays are expanded into individual rows, making every piece of configuration data accessible in the spreadsheet.
Key Benefits of Converting TOML to CSV:
- Spreadsheet Analysis: Open in Excel or Google Sheets for sorting and filtering
- Configuration Auditing: Compare settings across environments
- Database Import: Load configuration data into SQL databases
- Data Visualization: Create charts and dashboards from config data
- Dependency Tracking: List all project dependencies in tabular form
- Reporting: Generate configuration reports for stakeholders
- Universal Compatibility: CSV works with every data tool
Practical Examples
Example 1: Dependency Audit Spreadsheet
Input TOML file (Cargo.toml):
[package]
name = "web-api"
version = "2.0.0"
edition = "2021"
[dependencies]
actix-web = "4.4"
serde = { version = "1.0", features = ["derive"] }
sqlx = { version = "0.7", features = ["postgres", "runtime-tokio"] }
tracing = "0.1"
[dev-dependencies]
mockall = "0.11"
tokio-test = "0.4"
Output CSV file (Cargo.csv):
section,key,value,type package,name,web-api,string package,version,2.0.0,string package,edition,2021,string dependencies,actix-web,4.4,string dependencies,serde,1.0,string dependencies,serde.features,"derive",array dependencies,sqlx,0.7,string dependencies,sqlx.features,"postgres,runtime-tokio",array dependencies,tracing,0.1,string dev-dependencies,mockall,0.11,string dev-dependencies,tokio-test,0.4,string
Example 2: Environment Configuration Comparison
Input TOML file (production.toml):
[server] host = "0.0.0.0" port = 443 workers = 16 tls = true [database] host = "db-primary.internal" port = 5432 pool_size = 50 ssl = true [logging] level = "warn" format = "json" output = "stdout"
Output CSV file (production.csv):
section,key,value,type server,host,0.0.0.0,string server,port,443,integer server,workers,16,integer server,tls,true,boolean database,host,db-primary.internal,string database,port,5432,integer database,pool_size,50,integer database,ssl,true,boolean logging,level,warn,string logging,format,json,string logging,output,stdout,string
Example 3: Python Project Metadata Export
Input TOML file (pyproject.toml):
[project] name = "data-toolkit" version = "3.1.0" requires-python = ">=3.9" license = "MIT" [project.optional-dependencies] dev = ["pytest>=7.0", "black>=23.0", "mypy>=1.5"] docs = ["sphinx>=7.0", "furo>=2023.9"] [tool.black] line-length = 88 target-version = ["py39", "py310", "py311"]
Output CSV file (pyproject.csv):
section,key,value,type project,name,data-toolkit,string project,version,3.1.0,string project,requires-python,>=3.9,string project,license,MIT,string project.optional-dependencies,dev,"pytest>=7.0,black>=23.0,mypy>=1.5",array project.optional-dependencies,docs,"sphinx>=7.0,furo>=2023.9",array tool.black,line-length,88,integer tool.black,target-version,"py39,py310,py311",array
Frequently Asked Questions (FAQ)
Q: What is CSV format?
A: CSV (Comma-Separated Values) is a plain text format where each line represents a data record and fields within each record are separated by commas. It is one of the most universally supported data exchange formats, readable by spreadsheet applications (Excel, Google Sheets), databases, and virtually every programming language.
Q: How is TOML's hierarchical structure mapped to flat CSV rows?
A: Each TOML key-value pair becomes a row in the CSV. The section path (e.g., "dependencies" or "tool.black") is stored in one column, the key name in another, and the value in a third. Nested sections use dot notation in the section column. Arrays are expanded into comma-separated strings within quoted fields.
Q: Can I open the CSV in Microsoft Excel?
A: Yes! Simply double-click the .csv file or use File > Open in Excel. Excel will automatically parse the comma-delimited data into columns. You can then sort by section, filter by key names, or create pivot tables to analyze your configuration data. The same works with Google Sheets, Apple Numbers, and LibreOffice Calc.
Q: Are TOML data types preserved in the CSV output?
A: CSV itself has no data types (everything is text). However, the conversion can include an optional type column indicating whether each value was originally a string, integer, float, boolean, date, or array in the TOML file. This metadata helps when importing the CSV into typed systems like databases.
Q: How are TOML arrays represented in CSV?
A: TOML arrays are converted to comma-separated values within a quoted CSV field. For example, `features = ["derive", "serde"]` becomes `"derive,serde"` in the value column. Array of tables ([[section]]) are expanded into multiple rows with the same section path and incrementing indices.
Q: Can I import the CSV into a database?
A: Yes! CSV is the standard format for database imports. You can use MySQL's LOAD DATA INFILE, PostgreSQL's COPY command, SQLite's .import, or the import wizards in database management tools. This allows you to query your configuration data using SQL for auditing and comparison purposes.
Q: Can I convert the CSV back to TOML?
A: Converting CSV back to TOML is possible if the section, key, and value columns are preserved, along with type information. However, some structural details like comments, inline table formatting, and exact array syntax may not survive the round trip. It is best to keep the original TOML as the authoritative source.
Q: What delimiter does the CSV output use?
A: The output uses the standard comma delimiter as defined in RFC 4180. Fields containing commas, newlines, or double quotes are enclosed in double quotes. This ensures compatibility with all major spreadsheet applications and CSV parsers across different platforms.