Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TOML vs YAML

Here's the canonical TOML example from the TOML README, and a YAML version of the same. Which looks nicer?

title = "TOML Example"

[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00

[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8002 ]
connection_max = 5000
enabled = true

[servers]

  [servers.alpha]
  ip = "10.0.0.1"
  dc = "eqdc10"

  [servers.beta]
  ip = "10.0.0.2"
  dc = "eqdc10"

[clients]
data = [ ["gamma", "delta"], [1, 2] ]

hosts = [
  "alpha",
  "omega"
]
title: YAML Example

owner:
  name: Tom Preston-Werner
  dob: 1979-05-27T07:32:00-08:00

database:
  server: 192.168.1.1
  ports: [ 8001, 8001, 8002 ]
  connection_max: 5000
  enabled: true

servers:

  alpha:
    ip: 10.0.0.1
    dc: eqdc10

  beta:
    ip: 10.0.0.2
    dc: eqdc10

clients:
  data: [ [gamma, delta], [1, 2] ]

  hosts:
    - alpha
    - omega
@berney

This comment has been minimized.

Copy link

@berney berney commented Dec 5, 2017

Good example of TOML vs YAML. YAML looks better to my eyes rather than a mix between INI and YAML. I like the the same syntax for keys regardless of level in the tree, looks cleaner to me.

@udhos

This comment has been minimized.

Copy link

@udhos udhos commented Feb 16, 2018

YAML won this one.

@russmack

This comment has been minimized.

Copy link

@russmack russmack commented Feb 26, 2018

A matter of taste, I guess. For me, the YAML is too uniform, a sea of text with colons. I like TOML's quoted strings which immediately identify as strings, and the square brackets providing emphasis, more easily identified and located tables. As the "O" describes, I find the elements conveniently obvious.

@blizzardy

This comment has been minimized.

Copy link

@blizzardy blizzardy commented Mar 12, 2018

TOML better ! tabs or spaces is allowed, I like tabs

@tripleee

This comment has been minimized.

Copy link

@tripleee tripleee commented May 16, 2018

Anything which looks like INI makes me cringe. The real test would be something with a multi-line string, can you put newlines inside quotes and do you need a lot of backslashes?

@frankbe

This comment has been minimized.

Copy link

@frankbe frankbe commented Apr 27, 2019

I really like the INI format. It's more expressive than simple property files and sufficient for most use cases. YAML is sometimes good, but somehow awkward in the details. TOML is for me an unintuitive mix between YAML and INI, although I guess it's very expressive. When INI is not enough, I'd probably prefer JSON or XML.

@ExternalReality

This comment has been minimized.

Copy link

@ExternalReality ExternalReality commented Aug 13, 2019

Removing levels of nesting in favor of square brackets is a win for clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment