Lua Table to JSON

Convert Lua table literals into strict, formatted JSON directly in your browser.

How to convert a Lua table to JSON

Paste one Lua table literal into the input, then select Convert. You can include the optional return keyword. Copy or download the formatted JSON when the result looks right.

  • Use curly braces for the Lua table.
  • Use name = value or ["name"] = value for object fields.
  • Use plain values such as { "first", "second" } for a JSON array.

Lua table examples

These literal tables can be pasted directly into the converter. The last example shows that return is optional.

{
  name = "Maya",
  active = true,
  settings = { theme = "light" }
}

{ "validator", "formatter", "repair" }

return {
  project = "JSONPlease",
  versions = { 1, 2, 3 }
}

Safe local conversion

Lua table data literals are parsed locally without executing code. Tables, strings, numbers, booleans, nil, comments, and Lua separators are supported.

What this converter supports

Use data literals only: nested tables, strings, finite numbers, true, false, nil, comments, commas, semicolons, and long strings are supported. Object keys must be strings. A Lua table with values at indexes 1, 2, 3 and so on becomes a JSON array.

What cannot be converted

This tool never runs Lua code. Variables, function calls, expressions, require statements, and functions are rejected instead of being executed. Mixed object and array fields, missing numeric indexes, and non-string object keys are also rejected because JSON cannot represent them without changing their meaning.

Fix common Lua table errors

Check that every string is closed and every opening brace has a matching closing brace. For a Lua table that mixes named fields and plain array values, choose one shape before converting: use named fields for a JSON object or consecutive numeric values for a JSON array.

Related JSON tools