FormatForge

TOML to YAML Converter

Convert TOML to YAML format instantly. Transform Cargo.toml, pyproject.toml to YAML for Kubernetes, Docker Compose, and more. Free, secure, and works entirely in your browser.

TOML
YAML

Drop a file here or click to upload

Supports .toml files

Understanding TOML and YAML

TOML (Tom's Obvious, Minimal Language) is a configuration file format that emphasizes clarity and minimal syntax. It uses square-bracket table headers, dotted key paths, and explicit typing for strings, integers, floats, booleans, and dates. TOML is the native configuration format for Rust's Cargo package manager, Python's pyproject.toml (used by Poetry, pip, and setuptools), and the Hugo static site generator. For a complete reference on TOML syntax and semantics, visit our TOML guide.

YAML (YAML Ain't Markup Language) is a human-friendly data serialization format that uses indentation to express hierarchy. It supports mappings (key-value pairs), sequences (lists), and scalars (strings, numbers, booleans, null). YAML is the dominant configuration format in the DevOps ecosystem, powering Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Ansible playbooks, and Helm charts. To explore YAML anchors, multi-line strings, and common pitfalls, see our YAML guide.

Both TOML and YAML are popular configuration formats, but they serve different ecosystems. TOML is favored in the Rust and Python communities for its strict typing and unambiguous syntax, while YAML dominates in DevOps and cloud-native tooling. Converting between them is a common task when migrating projects or integrating tools from different ecosystems.

Why Convert TOML to YAML?

There are several practical scenarios where converting TOML configuration to YAML is essential:

  • Migrating Cargo or Hugo configs to YAML-based tools. When moving a Rust project's metadata into a CI/CD pipeline (GitHub Actions, GitLab CI) or converting a Hugo site's configuration to a YAML-first static site generator like Jekyll or Eleventy, TOML-to-YAML conversion is the first step.
  • Converting between configuration format ecosystems. Teams that standardize on YAML for all configuration (Kubernetes, Docker, Ansible) may need to convert TOML-authored settings from Python or Rust projects into the same format for consistency and tooling compatibility.
  • Generating Kubernetes or Docker Compose manifests from TOML data. If application metadata is defined in TOML (such as service names, ports, environment variables), converting it to YAML enables direct use in Kubernetes Deployments, Services, or Docker Compose stacks.
  • Sharing configuration with teams that prefer YAML. YAML's widespread adoption means many developers are more familiar with its syntax. Converting TOML to YAML can reduce friction when onboarding team members or sharing configuration across organizations.

How the Conversion Works

TOML-to-YAML is a cross-format conversion that uses JSON as an intermediate representation. The syntax mapping between the two formats is remarkably clean:

  1. Parse the TOML input using smol-toml, which validates the document against the TOML specification and extracts typed values.
  2. Convert to JSON intermediate. TOML tables become JSON objects, arrays of tables become JSON arrays, and scalar values are mapped to their JSON equivalents. TOML date/time values are converted to ISO 8601 strings.
  3. Serialize JSON to YAML using js-yaml, which produces properly indented YAML output with appropriate scalar styles (plain, quoted, block) based on the content.
  4. Apply formatting options such as indentation level and flow vs. block style based on user preferences.

The table below shows how TOML constructs map to their YAML equivalents:

TOML ConstructYAML Equivalent
[server] (table)server: (mapping)
port = 8080port: 8080
tags = ["api", "v2"]tags: - api - v2
[[routes]] (array of tables)routes: - ... (sequence of mappings)
enabled = trueenabled: true

Before and After Example

Below is a practical example showing a TOML configuration file (similar to a Cargo.toml or Hugo config) and its YAML equivalent after conversion.

Input TOML

[package]
name = "my-service"
version = "0.3.1"
edition = "2021"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.37", features = ["full"] }

[server]
host = "0.0.0.0"
port = 3000
workers = 4
debug = false

[[server.routes]]
path = "/health"
handler = "health_check"

[[server.routes]]
path = "/api/data"
handler = "get_data"

Output YAML

package:
  name: my-service
  version: 0.3.1
  edition: "2021"

dependencies:
  serde:
    version: "1.0"
    features:
      - derive
  tokio:
    version: "1.37"
    features:
      - full

server:
  host: 0.0.0.0
  port: 3000
  workers: 4
  debug: false
  routes:
    - path: /health
      handler: health_check
    - path: /api/data
      handler: get_data

Notice the clear syntax mapping: TOML tables become YAML mappings with indentation, inline tables expand to nested mappings, and arrays of tables ([[server.routes]]) become YAML sequences of mappings. The structure is preserved faithfully while the syntax shifts to YAML conventions.

Tips and Best Practices

Watch for YAML type coercion pitfalls

YAML auto-interprets certain values: yes/no as booleans, 1.0 as a float, and version strings like 3.10 as the number 3.1. The converter quotes ambiguous values to prevent unintended type changes, but always verify version numbers and similar strings in the output.

Understand inline table expansion

TOML inline tables like { version = "1.0", features = ["derive"] } are expanded into multi-line YAML mappings during conversion. This produces more readable YAML output but increases the file length. Both representations are semantically identical.

TOML date types become strings in YAML

TOML has native date, time, and datetime types that are serialized as ISO 8601 strings during conversion. Most YAML parsers will auto-detect these as timestamps, but if your target system needs a specific format, you may need to adjust the values after conversion.

Validate indentation in the YAML output

YAML is whitespace-sensitive -- incorrect indentation changes the meaning of the document. The converter always produces correctly indented output, but if you manually edit the YAML afterward, pay careful attention to consistent spacing, especially around nested sequences.

Use prettify for readable output

The prettify option produces clean, well-indented YAML that is easy to read and review. For machine consumption or API payloads, you can switch to minified output. Most DevOps tools expect prettified YAML, so the default setting works well for Kubernetes and Docker Compose files.

Related Tools

Explore other converters and resources that complement TOML-to-YAML conversion:

How to Convert TOML to YAML

  1. Paste your TOML data in the input area, or upload a TOML file
  2. Click the "Convert" button
  3. View the converted YAML output instantly
  4. Copy the result or download it as a file

Features

  • 100% client-side - your data never leaves your browser
  • No login or registration required
  • Instant conversion with real-time preview
  • Supports file upload and drag-and-drop
  • Download converted files directly
  • Works on mobile and desktop

Frequently Asked Questions

How does TOML to YAML conversion work?

The converter parses your TOML data into a JSON intermediate representation, then serializes that JSON into YAML syntax with proper indentation and formatting. TOML tables map to YAML mappings, arrays of tables become YAML sequences, and scalar types are preserved.

Why convert TOML to YAML?

YAML is the standard configuration format for Kubernetes, Docker Compose, GitHub Actions, Ansible, and many DevOps tools. Converting TOML to YAML enables integration with these platforms without manual rewriting of configuration files.

How are TOML dates and times handled in YAML?

TOML's native date, time, and datetime types are converted to ISO 8601 string representations in the YAML output. Most YAML parsers recognize ISO 8601 timestamps natively, ensuring seamless compatibility across systems.

Is there a difference in how TOML and YAML handle types?

TOML has stricter typing -- every value has an explicit type. YAML infers types from content, which means the string "true" might be parsed as a boolean. The converter handles this by quoting ambiguous YAML values when necessary to preserve the original TOML types.

Is my data secure during conversion?

Yes. All conversion happens entirely in your browser using client-side JavaScript. Your data is never transmitted to any server, stored remotely, or logged. You can verify this by using the tool with your network disconnected.

Can I convert multi-line TOML strings to YAML?

Yes. Multi-line basic strings and literal strings in TOML are preserved as multi-line strings in the YAML output. YAML supports several multi-line styles including literal blocks (|) and folded blocks (>), and the converter selects the most appropriate representation.