Direct answer: Lua works as a data format because it was built to be embedded: a full language whose interpreter fits in a few hundred kilobytes, extended by the host application with its own functions. When configuration needs loops, defaults or computed values, games and network gear accept Lua configuration directly.

Configuration starts as key-value pairs and drifts toward logic: defaults that depend on other values, lists built by loops, numbers computed from the environment. Static formats stall at that boundary, and the industry's most common workaround is embedding a real language. Lua is the language most often chosen for the job, and its design explains why.

The trending query Lua for data representation (2025) surfaced on the Hacker News front page in late November 2026, and the discussion behind it describes a settled industry pattern. Using a programming language as a configuration format is standard practice in games and network equipment, and the reasons are worth learning.

Built to live inside another program

Lua was designed to be embedded from its first release. The interpreter is tiny, a few hundred kilobytes, and the host application extends it with functions written in the surrounding program's language. The script side calls those functions; the host side decides what exists.

That design explains where Lua ships. Game engines use it for gameplay scripting, network devices use it for configuration and automation, and embedded devices use it because the footprint fits their memory budgets. A small, portable interpreter is easy to carry into constrained machines, and Lua has spent three decades refining exactly that niche.

When settings need logic

Static formats such as JSON and YAML describe data and stop there. Real configuration often wants more: fifty routes that differ in one field, a timeout derived from an environment variable, a list assembled from other entries. Writing all of that by hand in JSON means duplication, and duplicated settings drift apart silently.

Config-as-code solves it by making the configuration a program that returns a settings table. The host runs the script once at load, receives a plain data structure, and continues. The file gains loops and computed values, and the format keeps its shape because what comes out is still ordinary data.

Interpreter footprint at embed timeLua: a few hundred KBGeneral-purpose runtimes: many megabytesthe smaller bar is the one that fits in constrained devices
missedyour Brain mapquiz yourselfmasteredWatch your weak spots turn green.

Drop in your PDF - it doesn't leave your device.
Every miss becomes a red node on your map.
Free plan: 21 nodes, no card, no countdown.

Open Brain - free

The safety trade

A configuration language that can compute can also misbehave: it can loop forever, touch files or reach the network if the host permits it. Embedders handle this by sandboxing the interpreter, restricting the standard library to modules that cannot escape, and counting instructions so a runaway script halts instead of hanging the application.

The restriction is the product. A host that exposes only its own functions plus a curated subset of the language gets programmable configuration inside a hard perimeter, and that balance of expressiveness within limits is the entire trick.

A contested niche

Lua shares the niche with younger rivals. JSON5 loosens JSON's syntax, TOML targets readable static files, Dhall adds types and imports to configuration, and Starlark brings a restricted Python dialect to build systems. Each makes a different trade between safety and expression, and each finds hosts that value that trade.

FormatCan compute valuesTypical home
JSONNoAPIs and data interchange
TOMLNoProject configuration files
DhallYes, with typesConfiguration assembled from imports
StarlarkYes, restrictedBuild systems such as Bazel
LuaYes, sandboxed by hostGames, network gear, embedded devices

The lesson is that constraints decide formats: Lua's age and tiny footprint keep it winning in constrained devices, where thirty years of stability in a few hundred kilobytes is hard to replace.

Key takeaways

  • Lua was designed to be embedded: a tiny interpreter, a few hundred kilobytes, that hosts extend with their own functions.
  • Games and network gear ship Lua because constrained environments favor a small, portable, mature interpreter.
  • Static formats like JSON and YAML cannot express loops, defaults or computed values, which real configuration often needs.
  • Config that can compute can also misbehave, so embedders sandbox Lua and restrict its standard library.
  • JSON5, TOML, Dhall and Starlark contest the same niche, each trading safety against expression differently.

Quick answers

Why use a programming language as a config format?
Because settings frequently need loops, defaults and computed values that static formats cannot express.

How big is the Lua interpreter?
A few hundred kilobytes, small enough for embedded devices and easy to bundle inside a host application.

Is a Lua config safe?
It is as safe as the host makes it: embedders remove dangerous modules and cap instruction counts so scripts cannot hang or escape.

What languages compete in this niche?
JSON5, TOML, Dhall and Starlark each contest parts of it, while Lua's footprint keeps it ahead on constrained devices.

What does the host actually receive?
An ordinary data table: the script runs once at load and returns plain settings the application can use directly.

One thing to do tonight

Tonight, open the config or mod folder of a game or tool you use and search for Lua files. Finding the embedding pattern in the wild, once, makes it permanent.