Convert CSV to TOML

Drag and drop files here or click to select.
Max file size 100mb.
Uploading progress:

CSV vs TOML Format Comparison

Aspect CSV (Source Format) TOML (Target Format)
Format Overview
CSV
Comma-Separated Values

Plain text format for storing tabular data where each line represents a row and values are separated by commas (or other delimiters). Universally supported by spreadsheets, databases, and data processing tools. Simple, compact, and human-readable.

Tabular Data Universal
TOML
Tom's Obvious, Minimal Language

A minimal configuration file format designed to be easy to read due to its clear semantics. TOML maps unambiguously to a hash table and supports arrays of tables using [[double brackets]], making it ideal for representing structured records from CSV rows. Used extensively in Rust (Cargo.toml) and Python (pyproject.toml) ecosystems.

Configuration Structured Data
Technical Specifications
Structure: Rows and columns in plain text
Delimiter: Comma, semicolon, tab, or pipe
Encoding: UTF-8, ASCII, or UTF-8 with BOM
Headers: Optional first row as column names
Extensions: .csv
Structure: Key-value pairs with sections and arrays of tables
Data Types: String, integer, float, boolean, datetime, array, table
Encoding: UTF-8 (required)
Specification: TOML v1.0.0 (2021)
Extensions: .toml
Syntax Examples

CSV uses delimiter-separated values:

Name,Age,City
Alice,30,New York
Bob,25,London
Charlie,35,Tokyo

TOML uses [[arrays of tables]] for rows:

[[records]]
Name = "Alice"
Age = 30
City = "New York"

[[records]]
Name = "Bob"
Age = 25
City = "London"

[[records]]
Name = "Charlie"
Age = 35
City = "Tokyo"
Content Support
  • Tabular data with rows and columns
  • Text, numbers, and dates
  • Quoted fields for special characters
  • Multiple delimiter options
  • Large datasets (millions of rows)
  • Compatible with Excel, Google Sheets
  • Typed key-value pairs
  • Native integer, float, boolean types
  • Date and datetime values (RFC 3339)
  • Nested tables and inline tables
  • Arrays and arrays of tables
  • Multi-line strings (basic and literal)
  • Comments for documentation
Advantages
  • Smallest possible file size for tabular data
  • Universal import/export support
  • Easy to generate programmatically
  • Works with any spreadsheet application
  • Simple and predictable structure
  • Great for data exchange and ETL
  • Strongly typed values (strings, numbers, booleans)
  • Human-readable and easy to edit by hand
  • Unambiguous mapping to data structures
  • Standard in Rust and Python tooling
  • Supports inline comments
  • No trailing comma issues
  • Well-defined specification
Disadvantages
  • No formatting or styling
  • No data types (everything is text)
  • Delimiter conflicts in data
  • No multi-sheet support
  • No metadata or schema
  • Verbose for large datasets
  • No native tabular representation
  • Limited nesting compared to YAML/JSON
  • Smaller ecosystem than JSON or YAML
  • Not designed for big data
Common Uses
  • Data import/export between systems
  • Database bulk operations
  • Spreadsheet data exchange
  • Log file analysis
  • ETL pipelines and data migration
  • Application configuration files
  • Package manifests (Cargo.toml, pyproject.toml)
  • Static site generators (Hugo)
  • CI/CD pipeline configuration
  • Infrastructure as code settings
  • Structured data storage
Best For
  • Data exchange between applications
  • Bulk data import/export
  • Simple tabular data storage
  • Automation and scripting
  • Configuration with typed values
  • Structured record storage
  • Human-editable data files
  • Project metadata and manifests
Version History
Introduced: 1972 (early implementations)
RFC Standard: RFC 4180 (2005)
Status: Widely used, stable
MIME Type: text/csv
Introduced: 2013 (Tom Preston-Werner)
Current Version: TOML v1.0.0 (January 2021)
Status: Stable, active ecosystem
MIME Type: application/toml
Software Support
Microsoft Excel: Full support
Google Sheets: Full support
LibreOffice Calc: Full support
Other: Python, R, pandas, SQL, all databases
Rust (Cargo): Native support via Cargo.toml
Python: tomllib (3.11+), tomli, toml libraries
Go: BurntSushi/toml, pelletier/go-toml
Other: Hugo, Netlify, pip (pyproject.toml)

Why Convert CSV to TOML?

Converting CSV data to TOML format transforms flat tabular data into a structured, typed configuration format. While CSV treats all values as plain text strings, TOML preserves data types such as integers, floats, booleans, and dates. Each CSV row becomes a [[table entry]] in TOML, with column headers serving as key names and cell values correctly typed based on their content.

TOML's array of tables syntax ([[records]]) maps naturally to CSV rows, where each row becomes a separate table in the array. This representation is particularly useful when you need to import tabular data into applications that use TOML for configuration, such as Rust projects, Python build systems, or static site generators like Hugo. The converter automatically infers data types, so numeric columns become integers or floats, "true"/"false" values become booleans, and everything else stays as quoted strings.

This conversion is especially valuable for developers who need to seed configuration files from spreadsheet data. For example, you might maintain a list of server settings, feature flags, or product configurations in a CSV spreadsheet and then convert it to TOML for use in your application. The resulting TOML file is both machine-parseable and human-readable, making it easy to review and edit.

CSV to TOML conversion also supports generating structured data fixtures, creating deployment configurations from inventory spreadsheets, and building typed data files that can be validated against a schema. The converter handles delimiter detection, encoding normalization, and proper TOML escaping automatically.

Key Benefits of Converting CSV to TOML:

  • Type Inference: Automatically converts numeric, boolean, and date values to native TOML types
  • Array of Tables: Each CSV row becomes a [[records]] entry with proper key-value pairs
  • Auto-Detection: Automatically detects CSV delimiter (comma, semicolon, tab, pipe)
  • Header Recognition: CSV column headers become TOML key names
  • Human-Readable: TOML output is clean, well-formatted, and easy to edit manually
  • Configuration Ready: Output can be used directly in Rust, Python, and Go projects
  • Data Integrity: All cell values are preserved with correct types and proper escaping

Practical Examples

Example 1: Server Configuration Data

Input CSV file (servers.csv):

hostname,port,ssl_enabled,max_connections
web-01,8080,true,500
api-01,3000,true,1000
db-01,5432,false,100

Output TOML file (servers.toml):

[[records]]
hostname = "web-01"
port = 8080
ssl_enabled = true
max_connections = 500

[[records]]
hostname = "api-01"
port = 3000
ssl_enabled = true
max_connections = 1000

[[records]]
hostname = "db-01"
port = 5432
ssl_enabled = false
max_connections = 100

Example 2: Product Pricing Table

Input CSV file (products.csv):

name,sku,price,in_stock,category
Wireless Mouse,WM-100,29.99,true,Electronics
USB Keyboard,KB-200,49.99,true,Electronics
Monitor Stand,MS-300,19.99,false,Accessories

Output TOML file (products.toml):

[[records]]
name = "Wireless Mouse"
sku = "WM-100"
price = 29.99
in_stock = true
category = "Electronics"

[[records]]
name = "USB Keyboard"
sku = "KB-200"
price = 49.99
in_stock = true
category = "Electronics"

[[records]]
name = "Monitor Stand"
sku = "MS-300"
price = 19.99
in_stock = false
category = "Accessories"

Example 3: Environment Variables Mapping

Input CSV file (env_config.csv):

key,value,environment,required
DATABASE_URL,postgres://localhost/mydb,production,true
REDIS_HOST,127.0.0.1,production,true
DEBUG_MODE,false,development,false
LOG_LEVEL,info,production,true

Output TOML file (env_config.toml):

[[records]]
key = "DATABASE_URL"
value = "postgres://localhost/mydb"
environment = "production"
required = true

[[records]]
key = "REDIS_HOST"
value = "127.0.0.1"
environment = "production"
required = true

[[records]]
key = "DEBUG_MODE"
value = "false"
environment = "development"
required = false

[[records]]
key = "LOG_LEVEL"
value = "info"
environment = "production"
required = true

Frequently Asked Questions (FAQ)

Q: What is TOML format?

A: TOML (Tom's Obvious, Minimal Language) is a configuration file format created by Tom Preston-Werner (co-founder of GitHub) in 2013. It is designed to be easy to read and write, with clear semantics that map unambiguously to a hash table. TOML supports native data types including strings, integers, floats, booleans, dates, arrays, and tables. It is widely used in the Rust ecosystem (Cargo.toml), Python packaging (pyproject.toml), and static site generators like Hugo.

Q: How does the CSV delimiter detection work?

A: Our converter uses Python's csv.Sniffer to automatically detect the delimiter used in your CSV file. It supports commas, semicolons, tabs, and pipe characters. The sniffer analyzes a sample of your file to determine the correct delimiter and quoting style. This means your CSV files from Excel, Google Sheets, European locale software (which often uses semicolons), or database exports will all be handled correctly without any manual configuration.

Q: How are CSV data types converted to TOML types?

A: The converter performs automatic type inference on each cell value. Values that look like integers (e.g., "42") become TOML integers, decimal numbers (e.g., "3.14") become floats, "true"/"false" become booleans, and ISO date strings become TOML datetime values. All other values are stored as quoted TOML strings. This ensures the output TOML file is correctly typed and can be parsed by any TOML library without additional processing.

Q: Will my CSV headers be preserved as TOML keys?

A: Yes! The first row of your CSV file is used as the key names in the TOML output. Each subsequent row becomes a [[records]] entry where the header names are the keys and the cell values are the corresponding values. If your CSV has no header row, the converter generates generic key names (column_1, column_2, etc.). Header names are sanitized to be valid TOML keys.

Q: How does the converter handle special characters in CSV data?

A: Special characters in CSV cell values are properly escaped in the TOML output. Quotes, backslashes, and control characters are escaped according to the TOML specification. Multi-line values from quoted CSV fields are converted to TOML multi-line strings using triple quotes. This ensures the generated TOML is always syntactically valid.

Q: Can I use the TOML output in my Rust or Python project?

A: Absolutely! The generated TOML follows the TOML v1.0.0 specification and can be parsed by any compliant library. In Rust, you can use the toml or serde crate. In Python 3.11+, use the built-in tomllib module, or the tomli/toml third-party packages for older versions. The output is valid, well-formatted TOML that integrates seamlessly into any project.

Q: Is there a limit on the number of CSV rows?

A: There is no hard limit, but keep in mind that TOML is more verbose than CSV. Each row produces a [[records]] block with key-value pairs, so a CSV with 1,000 rows will generate a significantly larger TOML file. TOML is best suited for configuration-sized datasets (hundreds of records) rather than big data. For very large datasets, consider formats like JSON, Parquet, or keeping the data in CSV.

Q: Does the converter support CSV files from Excel?

A: Yes! CSV files exported from Microsoft Excel, Google Sheets, LibreOffice Calc, and other spreadsheet applications are fully supported. The converter handles both UTF-8 and UTF-8 with BOM encodings, as well as different line ending styles (Windows CRLF, Unix LF, Mac CR). Excel's default comma-separated format and locale-specific semicolon-separated formats are both detected automatically.

Q: What is the difference between TOML and YAML for configuration?

A: Both TOML and YAML are human-readable configuration formats, but they differ in philosophy. TOML uses explicit syntax with clear delimiters (= for assignment, [[]] for arrays of tables), making it less error-prone. YAML relies on indentation and has implicit typing that can cause surprises (e.g., "no" becomes a boolean). TOML is preferred when you want strict, unambiguous configuration, while YAML excels at deeply nested structures.