Advertisement

JSON to Lua Table

Convert JSON into Lua table constructors. Get an annotated sample table with EmmyLua type comments inferred from your JSON structure.

JSON input

Paste JSON, optionally name the root type, then generate.

Your Lua table code will appear here.
Advertisement

Tables are Lua's universal container

Lua has one data structure: the table. The generator converts your JSON into a table constructor with real example values, so you can paste it directly as config data or a test fixture.

Types via comments

Lua itself is dynamically typed, but EmmyLua annotations give editors the information to check your code. The generated comments describe each field's inferred type.

JSON to Lua Table FAQs

What does the output look like?
A Lua table literal populated with example values from your JSON, plus EmmyLua ---@type comments describing each field's type for editor support.
How are nested objects handled?
Nested objects become nested table literals, which is exactly how Lua represents structured data, since tables are Lua's only composite type.
How are arrays represented?
JSON arrays become Lua sequence tables {1, 2, 3}, using Lua's 1 based array convention inside a single table.
What are the EmmyLua comments for?
Editors like IntelliJ with EmmyLua read ---@type and ---@class comments to provide autocomplete and type checking in Lua code.
Where is this useful?
Game scripting (Roblox, Love2D, Garry's Mod), Neovim configs, and OpenResty all consume Lua tables, making this handy for config generation.
Advertisement