Skip to content

TypeScript to Lua Converter

Convert TypeScript code to Lua with automatic syntax transformation. Supports variables, functions, objects, arrays, and basic TypeScript features. Perfect for game development and scripting.

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

Conversion Options

0 characters
1 lines

Recommended Settings

Supported TypeScript Features

  • Variables: const/let/var → local with optional type comments
  • Functions: Function declarations and arrow functions → Lua functions
  • Objects: TypeScript objects → Lua tables with key = value syntax
  • Arrays: TypeScript arrays → Lua arrays (1-indexed by default)
  • Basic types: string, number, boolean, null/undefined → nil
  • Operators: ===, !==, &&, ||, ! → ==, ~=, and, or, not

Conversion Features

  • Type annotations preserved as Lua comments (optional)
  • Template literals converted to string concatenation
  • String concatenation (+) converted to Lua concatenation (..)
  • console.log() converted to print()
  • Semicolons automatically removed
  • TypeScript-specific syntax (types, interfaces) stripped

Pro Tips

  • Lua arrays are 1-indexed (start at 1) unlike TypeScript arrays (start at 0)
  • Type annotations are removed but can be preserved as comments
  • Complex TypeScript features (generics, classes, async) are not fully supported
  • Conversion happens client-side - your code never leaves your browser

Most Popular

Include type comments with local function style and 1-based indexing

When to Use This Tool

Game Development with Lua

Convert TypeScript game logic to Lua for engines like LÖVE, Corona SDK, or Roblox. Migrate TypeScript algorithms, data structures, and utility functions to Lua while preserving logic. Perfect for developers comfortable with TypeScript who need to work in Lua environments.

Script Migration

Migrate configuration scripts, automation tools, or data processing scripts from TypeScript to Lua. Convert build scripts, test utilities, or data transformation logic. Useful when transitioning projects from Node.js/TypeScript to Lua-based systems.

Learning Lua Syntax

Learn Lua syntax by seeing how TypeScript code translates. Write familiar TypeScript code and see the equivalent Lua output with type comments showing the mapping. Great educational tool for TypeScript developers learning Lua.

Code Prototyping

Prototype algorithms in TypeScript with type safety and IDE support, then convert to Lua for production. Write and test logic in TypeScript, convert to Lua for deployment in embedded systems, game engines, or other Lua environments.

Cross-Language Development

Maintain shared logic between TypeScript and Lua codebases. Convert utility functions, data models, or business logic from TypeScript to Lua. Keep TypeScript as source of truth and generate Lua versions automatically.

Lua Scripting for Apps

Convert TypeScript functions to Lua for embedding in applications that support Lua scripting. Many apps use Lua for user scripting or plugins. Write in TypeScript, convert to Lua for distribution.

How It Works

1

Paste TypeScript code into the input area

2

Tool parses code line-by-line using pattern matching

3

Variable declarations (const/let/var) converted to local

4

Functions and arrow functions converted to Lua function syntax

5

Objects converted to Lua tables with key = value syntax

6

Arrays converted to Lua arrays (optionally 1-indexed)

7

Type annotations stripped or preserved as comments

8

Operators converted (===→==, &&→and, ||→or, !→not)

9

String templates converted to concatenation (.. operator)

10

Copy converted Lua code or download as .lua file

100% Private

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

Lightning Fast

Powered by Pure JavaScript for optimal performance on modern browsers.

Secure

No data collection, no tracking, no sign-up required.

Frequently Asked Questions

What TypeScript features are supported?

Supports variables (const/let/var), functions (including arrow functions), basic objects, arrays, primitive types (string, number, boolean), and common operators. Does NOT support classes, interfaces, generics, async/await, imports/exports, or advanced TypeScript features. Best for simple scripts and utility functions.

How are TypeScript types handled in Lua?

TypeScript type annotations are removed since Lua is dynamically typed. Enable 'Include type comments' to preserve type information as Lua comments for documentation. For example, 'const x: string = "hello"' becomes 'local x = "hello" -- string' in Lua.

Why does Lua use 1-based array indexing?

Lua arrays start at index 1, unlike TypeScript arrays which start at 0. Enable 'Adjust to 1-based indexing' to note this difference. Be aware: if your TypeScript code relies on 0-based indexing logic, you'll need to manually adjust loop conditions and array access.

How are objects and arrays converted?

TypeScript objects become Lua tables with 'key = value' syntax instead of 'key: value'. TypeScript arrays become Lua arrays (tables with numeric indices). Nested objects and arrays are recursively converted. Example: {name: "Alice"} → {name = "Alice"}.

Can I convert TypeScript classes to Lua?

Classes are NOT fully supported in this MVP version. Lua uses tables with metatables for OOP, which requires complex mapping from TypeScript classes. For now, convert classes manually or restructure as functions and tables. Future versions may add class support.

How are template literals converted?

TypeScript template literals like `Hello, ${name}!` are converted to Lua string concatenation: "Hello, " .. name .. "!". Simple template expressions are supported. Complex nested templates may need manual adjustment.

What about async functions and Promises?

Async/await and Promises are NOT supported. Lua has coroutines which work differently from JavaScript Promises. You'll need to manually convert async patterns to Lua coroutines or callback-based approaches. This requires understanding both async models.

Is my TypeScript code sent to a server?

No! All conversion happens 100% client-side in your browser using JavaScript. Your TypeScript code never leaves your computer, is not sent to any server, and is not stored. The tool works completely offline after initial page load.