Skip to content
BENIBIX Learn

Transpiler

Development🌐 Web DevelopmentBuild Tools

Also known as Source-to-Source Compiler, Transcompiler

A tool that turns code in one language into another. People can still read it.

Think of it like

Think of it like a story put into plain words. Then more kids can read it.

Example

Emma writes her app in TypeScript. Before it ships, a tool turns each file into plain JavaScript.

Why it matters

It lets you write in a nicer language and still run everywhere.

Definition

A transpiler turns code in one language into code in another. On the web, it most often turns TypeScript or new JavaScript into older JavaScript. That older code runs in every browser. It is a kind of compiler, but its output is still code people can read. Babel and the TypeScript compiler are two well-known ones. It most often runs as part of the build.

Example code

typescript
// in:  const total: number = 5;
// out: const total = 5;
The type note is removed, leaving plain JavaScript.

Common mistake

Thinking a transpiler checks your types. Some only strip them out, so run the type checker too.

Key takeaways

  1. 1
    Code to code. Same level, new language.
  2. 2
    Readable output. Unlike machine code.
  3. 3
    Part of the build. Runs before you ship.

Compare