Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 39 ยท TOML, CSV and Other Formats

INI, .properties and Other Plain-Text Formats

Learn the simple line-oriented data formats still found everywhere - INI, Java .properties, TSV, logfmt and fixed-width records - with parsers you can run and the pitfalls of each dialect.

Not every format has braces or indentation. A large family of formats is simply one record per line, with a lightweight rule for splitting each line. They are easy to write by hand, easy to process with grep and awk, and easy to get subtly wrong because most have no formal specification. This lesson tours the ones you are most likely to meet: INI, Java .properties, TSV, logfmt, and fixed-width files. For .env files see Configuration Files; for CSV see CSV Parsing and Its Pitfalls.

INI files

INI is the classic configuration format of Windows and many Unix tools (php.ini, .gitconfig, my.cnf, setup.cfg, desktop files). It has sections in square brackets, keys with = (or :), and comments with ; or #.

INI
; global settings
name = demo

[database]
host = localhost
port = 5432
user = "admin"

[features]
beta = true

The dialects differ in many details. Does a key before any section belong to a "global" section? Are values trimmed? Do quotes mean anything? Can a key repeat to build a list? Are names case-insensitive? Is a trailing ; comment allowed on a value line? Because there is no standard, you need to read your tool's documentation. A parser must make these decisions explicitly.

Node.js An INI parser with typed values

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

This parser turns yes into a boolean. That is a convenience of this dialect, not a rule of INI itself; other tools keep everything as strings.

Java .properties

A .properties file is the standard resource format of Java applications (and Spring Boot's application.properties). Each line is key=value, key:value or key value. Comments start with # or !. A backslash at the end of a line continues the value on the next line, and \uXXXX escapes allow non-ASCII characters in the traditional ISO-8859-1 encoding (modern Java reads UTF-8).

PROPERTIES
# server
server.port=8080
app.title=My \
    Shop
greeting=Cafรฉ

Keys use dots by convention to suggest hierarchy (server.port), but the format itself is flat: the dots are just characters.

Node.js A .properties parser with continuation lines and unicode escapes

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

TSV and delimiter-separated text

TSV (tab-separated values) uses a tab as the delimiter. Because tabs rarely appear in data, TSV can often avoid quoting altogether, and many bioinformatics and analytics tools prefer it. The cost is that a tab or newline inside a value must be escaped (\t, \n) by convention, and spreadsheets may silently convert tabs in pasted text. The same dialect warnings as CSV apply.

logfmt

logfmt is a line-oriented structured-log format: space-separated key=value pairs, with quotes around values that contain spaces.

TEXT
level=info msg="user signed in" user=42 duration_ms=12.5

It is human-readable in a terminal and trivially parseable, which is why Heroku, Go's logging ecosystem and many tools adopted it. For nested data, JSON Lines is the usual choice.

Fixed-width records

Older systems (banking, government, mainframe exports) write fixed-width files: field 1 is characters 1 to 10, field 2 is characters 11 to 20, and so on. There are no delimiters and no quoting; a layout document tells you the columns. Parsing is slicing by position.

Node.js logfmt and fixed-width parsers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Choosing among them

Format Structure Best for Watch out for
INI sections, flat keys simple tool settings dialect differences, no nesting
.properties flat keys Java/Spring settings escapes, encoding
TSV table analytics exports tabs in data
logfmt one record per line logs no nesting or arrays
Fixed width table by position legacy exchange needs the layout document
flowchart TD
  A["Need structure?"] -->|"nested data"| B["JSON / YAML / TOML"]
  A -->|"flat settings"| C["INI / .properties / .env"]
  A -->|"table"| D["CSV / TSV"]
  A -->|"streaming log"| E["logfmt / JSON Lines"]

Pick the simplest format that fits the shape of your data.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is a section in an INI file?

    A header like [database] starts a section that lasts until the next header.
  2. 2. How does a .properties value continue on the next line?

    A backslash at the end of a line joins the next line (with its leading whitespace removed) to the value.
  3. 3. What is logfmt?

    logfmt writes structured log entries as key=value pairs, quoting values with spaces.
  4. 4. What is the main drawback of fixed-width files?

    There are no delimiters; positions define the fields, so the layout must be known.

Summary

  • INI, .properties, TSV, logfmt and fixed-width formats are all line-oriented and mostly unstandardised: check the dialect.
  • INI adds sections; .properties is flat with backslash continuation and unicode escapes.
  • logfmt suits structured logs; fixed-width suits legacy exchange.
  • All of them are flat: use JSON, YAML or TOML when your data is nested.
  • The parsers on this page are small teaching versions of real ones.

Next: JSON Lines and Binary Formats