Home › Developer Tools › TypeScript Playground

TypeScript Playground

Write TypeScript and get type errors as you type from the official compiler, then see the JavaScript it emits for your chosen target and run it with a built-in console. Everything runs in your browser.

Last updated:

Loading the TypeScript compiler…
Advertisement
Advertisement

How to use the TypeScript Playground

  1. Write or paste TypeScript in the editor, or pick an example from the list.
  2. Watch the status line and the Errors tab: type errors appear within a moment, with red line numbers in the editor gutter.
  3. Choose the target and module format to see how the emitted JavaScript changes, and toggle strict mode or DOM types.
  4. Click Run (or press Ctrl+Enter) to execute the code; output appears in the Console tab.
  5. Copy or download the JavaScript, view the .d.ts tab, or click Copy link to share the code.

How TypeScript turns into JavaScript

Compiling TypeScript does two independent things. The type checker reads your code and reports mismatches such as passing a string where a number is expected. The emitter removes the type annotations and, depending on the target, rewrites newer syntax into older JavaScript. Because the two are separate, the JavaScript is produced even when there are type errors, which is why this playground can show the output and run it while the Errors tab lists problems.

Compiler options in this playground

Optiontsconfig.json equivalentEffect
Target"target": "ES2020"JavaScript version of the output and the built-in library types (Promise, Map, Array.prototype.flat…)
Module"module": "ESNext"Keeps import/export, or converts them to require/exports (CommonJS)
strict"strict": trueEnables strictNullChecks, noImplicitAny, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization and more
noUnused…"noUnusedLocals", "noUnusedParameters"Reports variables, imports and parameters that are never used (prefix a parameter with _ to allow it)
DOM types"lib": ["ES2020", "DOM", "DOM.Iterable"]Adds type definitions for document, window, fetch and other browser APIs

Common error codes

CodeMessage (short)Typical fix
TS2322Type 'X' is not assignable to type 'Y'Change the value, widen the declared type or convert the value (for example Number(id))
TS2345Argument of type 'X' is not assignable to parameter of type 'Y'Pass the expected type or adjust the function signature
TS2339Property 'x' does not exist on type 'Y'Add the property to the interface, or narrow a union with in or a discriminant check
TS2531 / TS18047Object is possibly 'null'Check for null first, use optional chaining a?.b or a default with ??
TS7006Parameter 'x' implicitly has an 'any' typeAnnotate the parameter: (x: string) => …
TS2304Cannot find name 'x'Declare the variable, fix the spelling, or enable DOM types for browser globals
TS2307Cannot find module 'x'Imports of npm packages are not available in a single-file playground

Tip: when a type error is hard to read, assign the value to a variable with the type you expect (const check: Expected = value;) and read the more specific message that appears.

Frequently asked questions

Is this the real TypeScript compiler?

Yes. The page loads the official typescript package (version 5.6.3) and type-checks your code with the same compiler API that tsc and editors use, against the standard library definitions for the target you choose. The first load downloads a few megabytes, after which checking is instant.

Why does my code run even though it has type errors?

TypeScript types only exist at compile time. The compiler still emits JavaScript when there are type errors (unless noEmitOnError is set), so the playground runs the emitted code anyway and notes the number of errors in the console. Fix the errors to be sure the code behaves as typed.

What does the target option change?

The target is the JavaScript version the output must run on. ES2020 and newer keep modern syntax such as optional chaining, while ES2015 and ES5 rewrite it into older code, for example classes into functions on ES5 and async functions into generator helpers. The target also selects which built-in APIs the type checker knows about.

What does strict mode do?

strict turns on a family of checks including strictNullChecks, noImplicitAny, strictFunctionTypes and strictPropertyInitialization. With it, null and undefined must be handled explicitly and every value needs a known type. It is the recommended setting for new projects and is on by default here.

Can I import npm packages or use the DOM?

No packages can be imported: the playground checks a single file, so an import of a library reports that the module cannot be found. DOM types can be enabled for type checking, but the Run button executes code in a Web Worker without a page, so document and window are not available at run time.

Is my code sent to a server?

No. Compiling and running happen in your browser. The code is saved only in this browser's local storage, and the Copy link button puts it in the link itself, after the # sign, which browsers do not send to servers.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

TypeScript to JavaScriptConvert TypeScript or TSX to clean JavaScript instantly: strip types, keep or compile JSX.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.ESLint Config GeneratorGenerate a flat eslint.config.js for JavaScript, TypeScript, React or Node with rule presets.QR Code GeneratorMake QR codes for links, Wi-Fi, email and more.Barcode GeneratorCreate Code 128, EAN-13, UPC-A, EAN-8, Code 39 and ITF-14 barcodes as PNG or SVG.UUID GeneratorGenerate UUID v4 and v7 / GUIDs in bulk and copy or download them.Schema Markup Generator (JSON-LD)Create JSON-LD structured data for FAQ, Product, Article and more.Htaccess & Nginx Redirect GeneratorBuild 301 redirects for .htaccess, Nginx and Netlify or Cloudflare _redirects.Fake Data GeneratorGenerate mock data as JSON, CSV or SQL.Random String GeneratorGenerate secure random strings and tokens in bulk with any length and character set.API Key GeneratorCreate secure API keys and secrets with prefixes, checksums and SHA-256 hashes for storage.MIME Type LookupFind the MIME type for any file extension, or the extensions for a MIME type, in 400+ entries.Cron Expression GeneratorBuild crontab schedules visually, read them in plain English and see the next run times.URL Slug GeneratorTurn titles into clean, SEO-friendly URL slugs: accents, stop words, separators and bulk lines.JSON Schema GeneratorTurn sample JSON into a draft 2020-12 JSON Schema with types, required fields and formats.Gitignore GeneratorBuild a .gitignore from 50+ templates for languages, frameworks, IDEs and OS, merged and deduped.License GeneratorCreate a LICENSE file for MIT, Apache, GPL, BSD, ISC, MPL or Unlicense with your name and year.ULID GeneratorGenerate sortable ULIDs and UUID v7 in bulk, monotonic option, and decode their timestamps.Htpasswd GeneratorCreate .htpasswd entries with bcrypt, APR1-MD5 or SHA-1 for Apache and Nginx basic auth.Placeholder Image GeneratorCreate placeholder images in any size, color and text as PNG, JPG, WebP, SVG or data URI.Ads.txt GeneratorCreate or validate ads.txt and app-ads.txt files: seller lines, cert IDs and variables.Docker Run to Compose ConverterConvert docker run commands to docker-compose.yml, or a compose file back to docker run.Dockerfile GeneratorGenerate a production Dockerfile and .dockerignore for Node, Python, Go or a static nginx site.HTML Boilerplate GeneratorTick the options you need and get a clean HTML5 starter template with meta, OG tags and CSS reset.JSON to Zod SchemaInfer a Zod (or Yup) schema from sample JSON with optional, nullable and z.infer types.Linux Commands Cheat SheetSearchable Linux and bash command reference with flags explained, examples and copy buttons.LLMs.txt GeneratorBuild an llms.txt file for AI crawlers: summary and link sections, import from your sitemap.Nano ID GeneratorGenerate secure Nano IDs with custom alphabet, length and count, plus a collision calculator.Nginx Config GeneratorBuild an nginx server block: static site, SPA, reverse proxy or PHP, with SSL, gzip and redirects.OpenAPI / Swagger ViewerView OpenAPI 2/3 JSON or YAML as interactive API docs with validation and an endpoint list.package.json GeneratorFill a form and get a valid, npm-ready package.json with scripts, dependencies and checks.PKCE Code Challenge GeneratorGenerate an OAuth 2.0 PKCE code_verifier and S256 code_challenge, build auth URLs, verify pairs.README GeneratorFill in a form and get a polished README.md with badges, install, usage and license, live preview.Regex GeneratorBuild regular expressions visually from blocks or presets (email, date, phone) and test them live.Commit Message GeneratorBuild Conventional Commit messages with type, scope, body, breaking change and issue refs.Database Schema DesignerDesign tables and relationships visually, then export SQL for MySQL, PostgreSQL or SQLite.Dockerignore GeneratorBuild a .dockerignore from Node, Python, Go and Java templates, plus your own entries.Git Branch Name GeneratorTurn a ticket ID and title into a clean, valid git branch name like feature/PROJ-12-add-login.GitLab CI Config GeneratorGenerate a .gitlab-ci.yml with stages, jobs, images, cache, artifacts and rules from templates.Jinja2 Template TesterRender Jinja2 templates with YAML or JSON variables using real Jinja2, with clear error lines.JSON Schema Mock Data GeneratorGenerate realistic sample JSON from a JSON Schema: formats, patterns, $ref, seeds and counts.Kubernetes Secret GeneratorCreate Kubernetes Secret YAML from key/value pairs or .env with auto base64, or decode one.Kubernetes YAML ValidatorValidate Kubernetes manifests against the API schema of a chosen version, with error paths.Prettier Config GeneratorToggle Prettier options, preview formatted code live and copy your .prettierrc file.Quartz Cron GeneratorBuild and explain Quartz and Spring cron expressions with seconds, ?, L, W and #, plus next fire times.README Badge GeneratorCreate Shields.io-style README badges for license, version, build and custom labels.Systemd Service File GeneratorCreate a systemd .service unit with ExecStart, user, restart policy, environment and hardening.tsconfig.json GeneratorBuild a tsconfig.json with target, module, strict checks and path aliases, each option explained.Access Log AnalyzerAnalyze Apache and Nginx access logs: top URLs, IPs, status codes, bots and traffic charts.Regex String GeneratorGenerate random test strings that match any regular expression, checked against the real regex.ASCII Table GeneratorTurn CSV or pasted cells into plain-text tables: MySQL, Markdown, Unicode box and reST styles.Docker Compose GeneratorBuild a docker-compose.yml with a form: services, ports, volumes, env, healthchecks and presets.Dummy File GeneratorCreate test files of an exact size in KB, MB or GB with zeros, random bytes or text.FFmpeg Command GeneratorPick a task and options, get the exact ffmpeg command with every flag explained.Folder Tree GeneratorTurn a local folder or an indented list into an ASCII directory tree for your README.GitHub Actions Workflow GeneratorBuild a GitHub Actions CI workflow: triggers, matrix, caching, tests, Pages or Docker deploy.Kubernetes YAML GeneratorGenerate Deployment, Service, Ingress, ConfigMap, Secret and HPA manifests with safe defaults.Markdown TOC GeneratorGenerate a linked table of contents from Markdown headings with GitHub-style anchors.OpenAPI EditorEdit OpenAPI/Swagger YAML or JSON side by side with live API docs, validation and download.OpenAPI ValidatorValidate OpenAPI 3.0/3.1 and Swagger 2.0 specs: schema errors, broken $refs, line numbers.Pivot Table MakerBuild pivot tables from CSV or Excel by drag and drop: sum, count, average, charts, export.SQL Query BuilderBuild SELECT queries visually: joins, filters, GROUP BY, ORDER BY and LIMIT, as clean SQL.Truth Table GeneratorType a logic expression and get its full truth table, minterms and canonical DNF/CNF.Article Schema GeneratorCreate Article, BlogPosting or NewsArticle JSON-LD with headline, authors, dates and images.Event Schema GeneratorCreate Event JSON-LD with dates, venue or online location, tickets, organizer and performers.Google Search Query BuilderBuild advanced Google searches with site:, filetype:, intitle:, exact phrases and date operators.
See all 85 Code Generators & Builders →