Convert TOML to RST

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

TOML vs RST Format Comparison

Aspect TOML (Source Format) RST (Target Format)
Format Overview
TOML
Tom's Obvious Minimal Language

A minimal configuration file format created by Tom Preston-Werner in 2013. Designed with obvious semantics and a formally specified grammar. Supports typed values including strings, integers, floats, booleans, dates, arrays, and tables. Used in Cargo.toml, pyproject.toml, and many modern toolchains.

Modern Config Typed Values
RST
reStructuredText

A lightweight markup language used extensively in the Python documentation ecosystem. Part of the Docutils project and the primary format for Sphinx documentation generator. Supports rich document structures including headings, tables, code blocks, cross-references, directives, and roles for semantic markup.

Python Docs Sphinx Native
Technical Specifications
Structure: Hierarchical tables and key-value pairs
Encoding: UTF-8 required
Data Types: String, Integer, Float, Boolean, DateTime, Array, Table
Nesting: Tables and inline tables for hierarchy
Extensions: .toml
Structure: Document markup with directives and roles
Encoding: UTF-8 (default)
Data Types: Plain text with structural markup
Nesting: Section headings with underline characters
Extensions: .rst, .rest
Syntax Examples

TOML uses clear key-value syntax:

[project]
name = "my-package"
version = "1.2.0"
description = "A sample project"

[project.dependencies]
requests = ">=2.28"
click = ">=8.0"

RST uses structural markup:

Project
=======

- **name**: my-package
- **version**: 1.2.0
- **description**: A sample project

Dependencies
------------

- **requests**: >=2.28
- **click**: >=8.0
Content Support
  • Typed values (string, int, float, bool, date)
  • Tables for grouped configuration
  • Arrays and arrays of tables
  • Inline tables for compact data
  • Multi-line basic and literal strings
  • Offset date-time with timezone
  • Comment lines starting with #
  • Section headings with underline adornments
  • Bullet and numbered lists
  • Tables (grid, simple, csv, list)
  • Code blocks with syntax highlighting
  • Hyperlinks and cross-references
  • Directives for images, notes, warnings
  • Inline markup (bold, italic, code)
  • Table of contents generation
Advantages
  • Human-readable configuration
  • Rich type system prevents ambiguity
  • Formal specification at toml.io
  • Native array and table support
  • Growing ecosystem adoption
  • Unambiguous parsing rules
  • Powerful documentation markup
  • Native Sphinx integration
  • Rich directive and role system
  • Cross-reference capabilities
  • PDF, HTML, ePub output via Sphinx
  • Python ecosystem standard
  • Extensible with custom directives
Disadvantages
  • Newer format, still gaining adoption
  • Deep nesting can become verbose
  • Not designed for documentation
  • Limited to configuration use cases
  • No document formatting features
  • Steeper learning curve than Markdown
  • Whitespace-sensitive syntax
  • Less popular outside Python community
  • Complex directive syntax
  • Fewer editors with preview support
Common Uses
  • Rust projects (Cargo.toml)
  • Python packaging (pyproject.toml)
  • Hugo static site generator
  • Netlify configuration
  • Application settings files
  • Python project documentation
  • Sphinx documentation builds
  • ReadTheDocs hosted docs
  • API reference documentation
  • Technical specifications
  • Linux kernel documentation
Best For
  • Modern application configuration
  • Projects needing typed values
  • Rust and Python ecosystems
  • Hierarchical configuration data
  • Python library documentation
  • Technical reference documents
  • Sphinx-based documentation sites
  • Projects needing multi-format output
Version History
Introduced: 2013 (Tom Preston-Werner)
Current Version: TOML v1.0.0 (2021)
Status: Stable, formally specified
Evolution: Active development, growing adoption
Introduced: 2002 (David Goodger, Docutils)
Current Version: Docutils 0.20+
Status: Stable, mature
Evolution: Active via Sphinx extensions
Software Support
Cargo (Rust): Native support
Python: tomllib (3.11+), tomli, toml
Go: BurntSushi/toml, pelletier/go-toml
Other: Libraries for most languages
Sphinx: Native RST processing
Docutils: Reference implementation
Pandoc: RST read/write support
Other: VS Code, PyCharm, Sublime Text

Why Convert TOML to RST?

Converting TOML files to reStructuredText is valuable when you need to generate human-readable documentation from configuration data. Configuration files often contain critical project metadata, dependency lists, and settings that should be documented alongside your codebase. By converting TOML to RST, you can seamlessly integrate configuration documentation into Sphinx-based documentation projects without manual transcription.

TOML's structured tables and typed values translate well into RST's rich document markup. Table sections become RST headings, key-value pairs become definition lists or formatted tables, and arrays become bulleted lists. The resulting RST document provides a clear, readable representation of your configuration that can be included in your Sphinx documentation, rendered to HTML, PDF, or ePub, and kept in sync with the actual configuration file through automated conversion.

This conversion is particularly useful for Python projects that use pyproject.toml. The project metadata, build requirements, tool configurations, and dependency specifications stored in pyproject.toml can be automatically documented in RST format for inclusion in ReadTheDocs or similar documentation hosting platforms. This eliminates the common problem of configuration documentation falling out of sync with actual settings.

reStructuredText's directive system also allows the converted content to be enhanced with additional formatting, cross-references, and semantic markup that TOML cannot express. Once converted, you can add notes, warnings, code examples, and hyperlinks to create comprehensive documentation that goes beyond a simple configuration reference.

Key Benefits of Converting TOML to RST:

  • Documentation Integration: Include config data in Sphinx projects
  • ReadTheDocs Ready: Publish configuration docs online
  • Multi-Format Output: Generate HTML, PDF, ePub from RST
  • Automated Sync: Keep docs updated with config changes
  • Rich Formatting: Tables, code blocks, and cross-references
  • Python Ecosystem: Native format for Python documentation
  • Structured Content: Section hierarchy from TOML tables

Practical Examples

Example 1: Python Project Configuration Documentation

Input TOML file (pyproject.toml):

[project]
name = "data-pipeline"
version = "3.1.0"
description = "ETL pipeline for data warehousing"
requires-python = ">=3.10"

[project.dependencies]
pandas = ">=2.0"
sqlalchemy = ">=2.0"
apache-airflow = ">=2.8"

Output RST file (project-config.rst):

Project Configuration
=====================

Project
-------

- **name**: data-pipeline
- **version**: 3.1.0
- **description**: ETL pipeline for data warehousing
- **requires-python**: >=3.10

Dependencies
------------

.. list-table::
   :header-rows: 1

   * - Package
     - Version
   * - pandas
     - >=2.0
   * - sqlalchemy
     - >=2.0
   * - apache-airflow
     - >=2.8

Example 2: Cargo Project Documentation

Input TOML file (Cargo.toml):

[package]
name = "web-server"
version = "0.5.2"
edition = "2021"
authors = ["Jane Developer "]

[dependencies]
tokio = { version = "1.35", features = ["full"] }
axum = "0.7"
serde = { version = "1.0", features = ["derive"] }

Output RST file (cargo-config.rst):

Cargo Configuration
===================

Package
-------

:name: web-server
:version: 0.5.2
:edition: 2021
:authors: Jane Developer <[email protected]>

Dependencies
------------

**tokio** ``1.35``
   Features: full

**axum** ``0.7``

**serde** ``1.0``
   Features: derive

Example 3: Application Settings Reference

Input TOML file (settings.toml):

[cache]
backend = "redis"
ttl = 3600
max_entries = 10000

[cache.redis]
host = "127.0.0.1"
port = 6379
db = 0

[logging]
level = "INFO"
format = "%(asctime)s - %(name)s - %(levelname)s"

Output RST file (settings-ref.rst):

Application Settings Reference
==============================

Cache
-----

+---------------+----------+----------------------------+
| Key           | Type     | Value                      |
+===============+==========+============================+
| backend       | string   | redis                      |
+---------------+----------+----------------------------+
| ttl           | integer  | 3600                       |
+---------------+----------+----------------------------+
| max_entries   | integer  | 10000                      |
+---------------+----------+----------------------------+

Cache > Redis
~~~~~~~~~~~~~

- **host**: ``127.0.0.1``
- **port**: ``6379``
- **db**: ``0``

Logging
-------

- **level**: ``INFO``
- **format**: ``%(asctime)s - %(name)s - %(levelname)s``

Frequently Asked Questions (FAQ)

Q: How are TOML tables mapped to RST structure?

A: TOML tables ([section]) become RST section headings with appropriate underline characters. Nested tables create subsection hierarchies. Key-value pairs within tables are rendered as definition lists, field lists, or formatted tables depending on the content structure.

Q: Can I include the converted RST in my Sphinx documentation?

A: Yes, the output is valid RST that can be directly included in any Sphinx project using the .. include:: directive or by placing the file in your documentation source directory. It follows standard RST conventions and renders correctly with Sphinx.

Q: Are TOML data types preserved in the RST output?

A: RST is a documentation format without a type system, so TOML types become formatted text. However, type information can be indicated through formatting conventions -- for example, strings in quotes, numbers as-is, and booleans as true/false. Code formatting (backticks) is used for values to distinguish them from prose.

Q: How are TOML arrays represented in RST?

A: TOML arrays are converted to RST bullet lists. Arrays of tables become subsections with repeated structure. Inline arrays may be rendered as comma-separated items within a list entry, depending on complexity.

Q: Can I convert pyproject.toml to RST for ReadTheDocs?

A: Absolutely. This is one of the most common use cases. The project metadata, dependencies, and tool configurations from pyproject.toml translate cleanly into RST documentation that ReadTheDocs can build and host automatically.

Q: Will the RST output include a table of contents?

A: The converter generates properly structured RST sections that Sphinx can automatically include in a table of contents via the .. toctree:: directive. You can also add a .. contents:: directive to the converted file for a local table of contents.

Q: How does the converter handle multi-line TOML strings?

A: Multi-line TOML strings (both basic """ and literal ''') are converted to RST literal blocks or block quotes, preserving the original content and line breaks. This is particularly useful for documenting configuration values that contain long text.

Q: Can I customize the RST output format?

A: The converter produces standard RST that you can freely edit after conversion. You can add Sphinx directives, cross-references, admonitions (notes, warnings), and any other RST markup to enhance the documentation beyond what the TOML data provides.