Swelıty
Tools for everyone

Free Online TypeScript Playground

Run TypeScript online and see the console output and an HTML page together. Types are removed when the code runs, not checked.

Press Run, or Ctrl or Cmd + Enter, to run your code. The page shows in Preview and everything you log shows in Console. Use Stop if a script never ends. Types are removed when the code runs, not checked.

Preview

Console

Output appears here. Press Run, then try console.log("Hello")

How to use

  1. Write TypeScript in the main.ts tab, and any markup it needs in the HTML tab.

  2. Press Run, or Ctrl or Cmd + Enter, to run your code.

  3. Read what your code logs in the Console, and see the page in Preview. Errors are shown in red.

  4. Use Stop to end code that is still running, and the clear icon in the editor to start from scratch.

  5. Open the full screen editor for more room, and use the A buttons to resize the text.

  6. Press Format to tidy the tab you are editing, or untick Wrap long lines to scroll sideways instead.

Why use this tool

  • TypeScript syntax

    Type annotations, interfaces, type aliases, generics, enums and non-null assertions all run.

  • Top-level await

    Use await directly, because your code runs as a module.

  • Imports from https addresses

    Import modules from https URLs, for example from a CDN.

  • Preview and console together

    See the page and the console output side by side.

  • One-click formatting

    Tidy the indentation and spacing of the tab you are editing with one click or Shift + Alt + F.

  • Comfortable editor

    Resize the text, switch line wrapping on or off, or go full screen with the editor and preview side by side.

About this tool

Run TypeScript in your browser and read the output in a console. Write interfaces, generics, enums and type annotations, press Run, and see the result along with the page from the HTML tab. The types are stripped before the code runs, so this is a fast way to try TypeScript syntax and logic. It does not check types or report type errors.

Frequently asked questions

No. Types are removed with Babel's TypeScript support so the code can run, and type errors are not reported. Use your editor or the official TypeScript tools to check types.

Anything Babel can strip or compile, such as annotations, interfaces, type aliases, generics and enums. A few features, such as const enums and some uses of namespaces, may not behave exactly like the TypeScript compiler.

Yes. The compiler is loaded from a public CDN the first time you run your code. It is about 3 MB, so the first run can take a moment. Your browser keeps it afterwards.

Press Stop to end it. The preview runs separately from the rest of the page, so you can still use the page while it runs.

Not unless you turn on Auto-run, which is off by default. It never runs by itself when the page loads, except the built-in example on a first visit.

Yes. Press Format, or Shift + Alt + F while you are typing, to tidy the tab you are editing. If the code has a syntax error it is left unchanged and the problem is shown under the editor.

Yes. Untick Wrap long lines under the editor and it scrolls sideways instead. Your choice is remembered on this device.