TOML language erlang parser
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

TOML language Erlang parser

A pure Erlang parser for TOML.

  • It implements all defined elements (according to version f68d014bfd).
  • It is fast. It can parse about 15Mbytes/sec on an Core2 Duo Macbook.
  • It detects many errors, and returns the error type and line number.


git clone
cd etoml
make test

$ erl -pa ebin
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]

Eshell V5.9.2  (abort with ^G)
1> etoml:parse("key=1").

You can also include etoml in your application as a rebar dependency in your rebar.config file:

{deps, [{etoml, ".*",{git, "", master}}]}.


The usual TOML example

# This is a TOML document. Boom.

title = "TOML Example"

name = "Tom Preston-Werner"
organization = "GitHub"
bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
dob = 1979-05-27T07:32:00Z # First class dates? Why not?

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


  # You can indent as you please. Tabs or spaces. TOML don't care.
  ip = ""
  dc = "eqdc10"

  ip = ""
  dc = "eqdc10"

data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it

# Line breaks are OK when inside arrays
hosts = [

is parsed calling etoml:parse/1 as:

		{<<"title">>, <<"TOML Example">>},
     	{<<"owner">>, [
     		{<<"dob">>, {{1979,5,27},{7,32,0}}},
       		{<<"bio">>, <<"GitHub Cofounder & CEO\nLikes tater tots and beer.">>},
       		{<<"organization">>, <<"GitHub">>},
       		{<<"name">>, <<"Tom Preston-Werner">>}
     	{<<"database">>, [
     		{<<"enabled">>, true},
       		{<<"connection_max">>, 5000},
       		{<<"ports">>, [8001,8001,8002]},
       		{<<"server">>, <<"">>}]},
     		{<<"servers">>, [
     			{<<"beta">>, [
     				{<<"dc">>, <<"eqdc10">>},
     				{<<"ip">>, <<"">>}
       			{<<"alpha">>, [
       				{<<"dc">>, <<"eqdc10">>},
       				{<<"ip">>, <<"">>}
     	{<<"clients">>, [
      		{<<"hosts">>, [<<"alpha">>,<<"omega">>]},
       		{<<"data">>, [
       			[<<"gamma">>, <<"delta">>],

etoml generates an intermediate parse result that can also be useful. If etoml:parse2/1 is used instead of etoml:parse/1 the result is:

{ok,[{[<<"title">>],<<"TOML Example">>},
    	 {[<<"owner">>,<<"name">>],<<"Tom Preston-Werner">>},
      	<<"GitHub Cofounder & CEO\nLikes tater tots and beer.">>},
     	{[<<"clients">>,<<"data">>], [[<<"gamma">>,<<"delta">>],[1,2]]},