TOML Datatypes

This tutorial covers basis of Toml file data types with examples ..

Toml data types

In Toml documents, value data must support following types

  • a String
  • a Integer
  • a Float
  • a boolean
  • a date and time types(Offset Locl date, times)
  • an array
  • an inline table

toml value can not support following types

  • Binary data
  • Infinity and NAN
  • undefined
  • functions

TOML Strings

value strings accepts basic strings, multiple line strings,literals and multiple line lierals values of strings can be represented in double quotes as follows,


Multiple lines of strings also accepted as values, Multi line strins are enclosed in three quotations as follows statement=“”” I am statement with multi line strings “”“”

Literal values are enclosed in single quotes as follows


multi line litera values are enclosed by three single quotes as follows

lines=“’ this is multiple lines literals example”’

TOML Integer types

values in a documents accepts positive and negative values


key1=+45 # positive number value key2=-20 # negative number value

Big integers are expressed with underscore as follows key3=300_000

values can also accept heax decimal,octal and binary numbers

key5=0xDFA1 # prefix 0X for hex decimal numbers key6=0o746 # prefix 0o for octal numbers key6=0b1001 # prefix 0b for binary numbers

TOML Float types

float numbers contains integers and decimal numbers separated by . dot


keyfloat1=+1.5 keyfloat1=-1.5

TOML Boolean types

boolean are of true and false in lower cases accepted as values

key_true=true key_false=false

TOML Date types

Following are supported date formats, Date must be as per RFC 3339

OffsetDate Time Local Date Time Local Date Local Time


offsetdatetime-key=2020-02-20T06:10:20Z # offset Date time
offsetdatetime-key1=2020-02-20 06:10:20Z # offset Date time - T is replaced with spaces also
localdatetime-key=2020-02-20 06:10:20 # local Date time
date-key=2020-02-20 #  Date type
time-key=06:10:20 #  Time type

TOML Array type

Like any programming languages, This also provides arrays, arrays are used to group the elements refered with a single variable name. Syntax

  • Array-values are enclosed with square brackets
  • Double quotes are not required
  • spaces are not considered
  • each value in a Array-Values are separated by comma symbol
  • value contains of same types - strings,numbers etc.. or of mixed types- (string and numbers)
  • values contains multiple lines with line break or enter

Array of strings/numbers Example

Array values contains same type of data ie strings

numbers=[1,2,3,4] # array of numbers
weekends=["SATURDAY","SUNDAY"] # array of strings
floatarray=[1.0,3.5] # array of floats
mixed-array-1=[1,"one"] # array of mixed type

nested array examples

nested array is a array of arrays, each element in an array contains array of values

nested-array-key=[[2,3],[5,6]] # nested array of numbers
  ] # nested array of mixed types

Table Data type

One of the important type is type which is representation of HashTable or properties object in other programming language. Table stores the collection of key and values under a one name

__ Syntax __

      #line break

Table type rules

  • First line of table is enclosed in a square bracket
  • Last line must be EOF or specify the next table
  • data in table is unordered
  • All the data type rules are applied to table data
  • spaces are ignored
  • Tables without data is valid
  • Duplicate tables are not allowed



Inline Table type

This is other way of expressing data in table format examples



  • Inline tables data is enclosed in curly braces
  • All the data placed in single line
  • New line inside braces are invalid
Prev Next Next