メインコンテンツへスキップ
Z

JSON vs XML

JSON vs XML compared — verbosity, schema, attributes, parsing and use cases, with free formatters and converters for both.

JSON and XML both serialise structured data, but JSON is lighter and now the default for web APIs, while XML offers richer document features — attributes, namespaces and schema validation — that still matter in enterprise and document-centric systems.

JSON vs XML at a glance

JSON XML
Verbosity Compact Verbose (closing tags)
Attributes No (key/value only) Yes (element attributes)
Schema JSON Schema (optional) XSD/DTD (mature)
Namespaces No Yes
Parsing Native in JS, fast Heavier (DOM/SAX)
Typical use Web/REST APIs Documents, SOAP, config, feeds

When to use JSON

Choose JSON for web and mobile APIs — smaller payloads, native browser support and simpler parsing make it the modern default.

When to use XML

Choose XML when you need attributes, namespaces, mixed content or strict schema validation — document formats, SOAP services and many enterprise integrations still rely on it.

Tools for JSON & XML

JSON vs XML

属性はどのように表現されますか?

各属性は(カスタマイズ可能な)`@`プレフィックス付きのキーになります。`<note to="Tove">`は`{"@to": "Tove"}`になります。

同じタグが親要素の中で複数回繰り返される場合はどうなりますか?

同じタグ名を持つ子要素が繰り返されている場合は、1つのJSON配列にまとめられます。

混在コンテンツはどのように処理されますか?

テキストコンテンツは子要素と並んで(カスタマイズ可能な)`#text`キーの下に配置されます。

逆方向の変換が必要な場合は?

<a class="text-brand-600 hover:underline" href="/json-to-xml">JSON to XML</a>をご覧ください。整形(pretty-print)だけが必要な場合は<a class="text-brand-600 hover:underline" href="/xml-formatter">XML Formatter</a>が便利です。出力されたJSONはそのまま<a class="text-brand-600 hover:underline" href="/json-formatter">JSON Formatter</a>で利用できます。