YAML & TOML 設定完全ガイド

Free Kubernetes · Docker · Rust · Python · GitHub Actions No signup · No data stored · Works offline

このガイドで紹介するツール

YAML Formatter & Validator
Format Kubernetes, Docker & CI/CD YAML
YAML to JSON Converter
Resolve anchors and convert to JSON
TOML Formatter & Validator
Format Cargo.toml and pyproject.toml
TOML to JSON Converter
Convert TOML configuration to JSON
JSON to YAML Converter
Convert JSON config to YAML format
JSON to TOML Converter
Convert JSON to Rust/Python config
Cron Expression Generator
Build cron schedules for CI/CD pipelines
Regex Tester
Test patterns used in config templating
Last updated: March 2026  ·  v1.0
Quick Answer
YAMLとTOMLの違いは何か、どちらをいつ使うべきか?

YAMLとTOMLはどちらも人間が読めるconfig形式ですが、用途が異なります。5つの重要な違い:

  1. YAMLを使う:Kubernetes、Docker Compose、GitHub Actions。
  2. TOMLを使う:Cargo.toml(Rust)、pyproject.toml(Python)。
  3. YAMLはインデントで階層を表現し、TOMLは明示的な[section]ヘッダーを使う。
  4. TOMLは強型付け;YAML 1.1はyes/noを暗黙的にbooleanに変換する。
  5. YAMLでのタブ文字は常に解析エラーを引き起こす——スペースのみ使用すること。

Configuration files define how your software behaves in every environment. YAML and TOML have become the dominant formats for modern developer tooling: Kubernetes uses YAML, Rust's Cargo uses TOML, and Python packaging has adopted TOML in pyproject.toml. This guide covers what you need to know about both formats, their common pitfalls, and how to move data between them.

YAML fundamentals for Kubernetes and Docker

YAML (YAML Ain't Markup Language) uses indentation to represent hierarchy — there are no braces or brackets. This makes it clean to read but notoriously sensitive to whitespace errors.

Indentation rules: YAML uses spaces only — never tabs. The number of spaces must be consistent within a document (2 or 4 spaces per level are standard). A single tab character anywhere in a YAML file causes a parse error.

Key-value pairs: Written as key: value with a mandatory space after the colon. Missing the space (key:value) is a common error.

Strings: Most strings don't need quotes. You need quotes when the value contains special characters or could be misinterpreted as a boolean. YAML 1.1 treats yes, no, true, false, on, off as booleans.

Multi-document YAML: Use --- to separate multiple documents in a single file — common in Kubernetes manifests that define multiple resources.

Common YAML errors in Kubernetes and Docker Compose

Tab characters — The most common and hardest to spot. Configure your editor to show whitespace characters and enforce spaces-only for YAML files.

Inconsistent indentation — Mixing 2-space and 4-space indentation in the same file causes silent structural errors. Use our YAML Formatter to normalise indentation in one click.

Implicit type coercion — YAML 1.1 treats yes/no/on/off as booleans and bare numbers as integers or floats. A port value of 0800 gets parsed as octal 512. Always quote ambiguous values.

Anchor and alias errors — YAML anchors (&name) and aliases (*name) are powerful but confusing. Our YAML to JSON Converter resolves anchors and shows the fully expanded result.

TOML: the configuration format for Rust and Python

TOML (Tom's Obvious Minimal Language) was designed specifically for configuration files that humans edit directly. Unlike YAML, TOML is unambiguous — there is no indentation to miscount and no implicit type coercion.

Key sections: TOML uses [section] headers instead of indentation. A Cargo.toml file has sections like [package], [dependencies], and [dev-dependencies].

Array of tables: The [[table]] syntax creates an array of objects — used for things like multiple binary targets in Cargo.toml.

Types: TOML is strongly typed. It distinguishes integers, floats, booleans, strings, datetime, arrays, and inline tables. There is no implicit coercion — port = 8080 is always an integer.

Comments: Unlike JSON, TOML supports comments with #. This makes it ideal for configuration files where you want to explain each setting inline.

When to use YAML vs TOML vs JSON for configuration

Use YAML when the tooling requires it (Kubernetes, Helm, Ansible, most CI/CD systems), when you need comments and anchors, or when the config is primarily written and read by machines.

Use TOML when humans edit the file directly and correctness matters more than compactness. Rust's Cargo.toml, Python's pyproject.toml, and Hugo's config.toml are canonical examples.

Use JSON when the config is consumed by JavaScript/Node.js code (package.json, tsconfig.json), or when you need the simplest possible format with maximum parser support.

Converting between these formats is straightforward: our JSON to YAML, JSON to TOML, YAML to JSON, and TOML to JSON converters handle the translation in your browser.

Frequently asked questions about YAML and TOML

Kubernetes の YAML がローカルでは動くのに CI で失敗するのはなぜですか?

最も多い原因は、タブとスペースのインデントの違いです。一部のエディターはタブを気づかないうちに挿入します。コミット前に、YAML フォーマッターで YAML を通して空白を正規化してください。

YAML にコメントを追加できますか?

はい。YAML は # でコメントをサポートします。# から行末までは無視されます。これは設定ファイルにおいて JSON より YAML が優れている主な点の一つです。

TOML v0.5 と TOML v1.0 の違いは何ですか?

TOML v1.0(2021年リリース)は、複数行文字列、Unicode のキー名、日時形式にまつわるエッジケースを明確化しました。最新のツールのほとんど(Cargo 1.54 以降、Python の tomllib)は v1.0 を使います。私たちのフォーマッターは v1.0 に準拠しています。

Kubernetes の YAML マニフェストを JSON に変換するにはどうすればよいですか?

YAML→JSON コンバーターを使います。マニフェストを貼り付けて Convert をクリックしてください。出力は kubectl やほとんどの Kubernetes クライアントが受け付ける有効な JSON です。

pyproject.toml が JSON や YAML ではなく TOML を使うのはなぜですか?

Python パッケージングのコミュニティが TOML を選んだのは、(JSON と違って)コメントをサポートし、(YAML の暗黙的な型と違って)曖昧さがなく、人間にやさしいからです。PEP 518(2016年)がこの目的で TOML を指定しました。