String interpolation for Lua
Switch branches/tags
Nothing to show
Clone or download


String interpolation for Lua, inspired by f-strings, a form of string interpolation coming in Python 3.6.

This module started as a blog post showcasing that Lua already has all features necessary to implement the equivalent Python feature.


Require the F module and then use it directly on strings. Any {expression} occurring in them will be evaluated and interpolated directly in the string.

local F = require("F")

local f = 99
local c = (f - 32) / 9 * 5
print(F"{f} degrees Fahrenheit is {c:%.2f} degrees Celsius")

Almost any Lua expression can be inserted (apart from two minor parsing caveats: ":%" is used as a separator for specifying formatting (according to the same rules of string.format), and curly braces within expressions must be well-nested).

See the examples directory for more examples.


Hisham Muhammad - -


MIT/X11, the same as Lua.