Skip to content

Lua to TypeScript Converter

Convert Lua table literals to TypeScript interfaces or type aliases with full type inference and configurable output options

Category: code
Use Case: Game Development, Type Safety, Code Migration
Privacy: 100% browser-based

Conversion Options

Recommended Settings

Best Practices

  • Always validate generated types with your TypeScript compiler before use
  • Keep original Lua files as source of truth for game data
  • Use readonly modifiers for immutable configuration data
  • Test edge cases like empty tables, nested structures, and nil values

Type Safety Tips

  • Enable 'Export types' to use interfaces across multiple files
  • Use 'Make null optional' for safer handling of nil Lua values
  • Preserve original keys when matching existing Lua naming conventions
  • Sort keys alphabetically for better code organization and diffing

Most Popular

Most users convert Lua game configuration with exported interfaces, 2-space indentation, and optional null handling

When to Use This Tool

Game Development

Add TypeScript type safety to Lua game configurations from engines like LÖVE, Corona, or Roblox. Generate interfaces for player data, level configurations, item definitions, and game settings to catch type errors at compile time.

Code Migration

Migrate Lua-based projects to TypeScript by converting configuration files and data structures. Maintain type safety during the transition while preserving the original Lua data format for backwards compatibility.

API Type Definitions

Create TypeScript type definitions for Lua-based APIs and data contracts. Share type-safe interfaces between Lua backend services and TypeScript frontend applications for better integration and fewer runtime errors.

Documentation

Generate self-documenting TypeScript interfaces from Lua configuration files. Use the type definitions as living documentation that stays in sync with your actual Lua data structures.

How It Works

1

Paste your Lua table literal into the input field

2

Configure conversion options (interface/type, export, naming)

3

Click Convert to TypeScript to process

4

luaparse parses the Lua syntax into an AST

5

The converter infers TypeScript types from Lua values

6

Nested tables are extracted as separate interfaces

7

Download or copy the generated TypeScript code

100% Private

Files never leave your device. All processing happens locally in your browser.

Lightning Fast

Powered by luaparse for optimal performance on modern browsers.

Open Source

Built with verified, open-source libraries. Fully transparent.

Frequently Asked Questions

What Lua syntax is supported?

This tool supports Lua table literals including nested tables, strings, numbers, booleans, and nil values. It handles both array-style tables (sequential numeric keys) and dictionary-style tables (string keys). Functions, metatables, and executable code are not supported - only data structures.

How are Lua types mapped to TypeScript?

Lua tables with sequential numeric keys become TypeScript arrays (T[]). Tables with string keys become interfaces or type aliases. Lua strings, numbers, and booleans map directly to their TypeScript equivalents. Nil values become null or optional properties depending on your settings.

Can I convert Lua functions or code?

No, this tool only converts Lua table literals (data structures). It cannot convert executable Lua code, function definitions, or code with metatables. If you need to convert configuration data that includes functions, extract just the data portions first.

What's the difference between interface and type?

Interfaces and type aliases are similar in TypeScript. Interfaces can be extended and merged, making them better for public APIs and libraries. Type aliases are more flexible and can represent unions and complex types. For Lua table conversions, either works fine - choose based on your TypeScript project conventions.

Why should I make properties readonly?

Readonly properties prevent accidental modifications to configuration data. This is especially useful for Lua game configurations or settings that should remain immutable after loading. Enable this option for const-like behavior in TypeScript.

How are nested Lua tables handled?

Nested Lua tables are automatically extracted as separate TypeScript interfaces. The converter analyzes the structure, creates appropriately named interfaces for nested objects, and references them in the parent interface. This keeps types organized and reusable.