Stop Switching Between ts-node and tsc: Run TypeScript Directly with tsx
You know the drill: you're prototyping a script, you've written it in TypeScript because that's your language of choice, and now you need to actually run it. So you reach for ts-node, or you set up a build step with tsc, or you fiddle with tsx from the command line and hope the flags are right. It's friction you don't need. What if you could just run a .ts file directly, the same way you'd run a .js file? That's exactly what tsx promises to deliver.
tsx, short for "TypeScript Execute," is a tool that lets you run TypeScript files in Node.js without a separate compilation step. No config files, no watch mode setup, no "wait, did I rebuild?" moments. You just point Node at your TypeScript and it works.
What It Does
At its core, tsx is a wrapper around Node.js that handles the TypeScript compilation on the fly. Instead of requiring you to pre-compile your code or use a separate process, it hooks into Node's module loading system. When you run tsx on a file, it transpiles the TypeScript to JavaScript in memory, then executes it with Node's runtime.
The project is built on top of esbuild, which is a key detail. esbuild is known for being exceptionally fast at transpilation—it's written in Go and designed for speed. This means tsx isn't just convenient; it's also quick. The overhead of running a TypeScript file is minimal because the transpilation is happening at near-native speed.
The README frames it simply: "The easiest way to run TypeScript in Node.js." That's the whole pitch. It's a single tool that handles the gap between writing TypeScript and executing it. You don't need to think about tsconfig settings for runtime, you don't need to worry about whether your target environment supports certain syntax—tsx handles the conversion for you.
Why It's Cool
There are a few things that make tsx stand out from the crowd of TypeScript runners.
It's genuinely zero-config. You don't need a tsconfig.json just to run a script. You don't need to install typescript separately. You install tsx and you're done. That's a huge win for quick scripts, one-off utilities, or just testing an idea without setting up a whole project structure.
It's fast, and it feels fast. Because it leverages esbuild, the transpilation is swift. If you've ever waited for ts-node to spin up and compile your code, you'll appreciate the difference. tsx aims to get out of your way, and the esbuild foundation is what makes that possible.
It's drop-in simple. The usage pattern is exactly what you'd expect. You have a file called script.ts? You run tsx script.ts. That's it. There's no mental overhead about which command to use or what flags are required. It works the way you wish Node.js natively worked.
It's a single dependency. Instead of juggling typescript, ts-node, and maybe nodemon for watching, you get one package that does the job. For small projects or scripts, that's a cleaner dependency tree and less to maintain.
The project also has active sponsorship and a development repo, which suggests it's not just a weekend hack—it's a tool that's being maintained and improved. The README links to full documentation and a getting-started guide, so there's real substance behind the simple pitch.
How to Try It
Getting started is about as straightforward as it gets. First, install tsx in your project:
npm install tsx
Or if you prefer using it without installing globally, you can use npx:
npx tsx your-script.ts
Once it's installed, you run your TypeScript files directly:
tsx script.ts
That's the whole workflow. You write your TypeScript, you run it, you iterate. No build step, no config, no waiting. If you want to dig deeper, the documentation and getting started guide are linked from the repo, and the project itself is at github.com/privatenumber/tsx.
Final Thoughts
tsx is one of those tools that solves a small but persistent annoyance so well that you wonder why it took so long to exist. It's not trying to be a full build system or a replacement for a bundler—it's just making the act of running TypeScript in Node.js feel natural. If you write scripts, prototype quickly, or just want to avoid the ceremony of a build step for small tasks, this is worth adding to your toolkit. It won't replace your production build pipeline, but for the day-to-day "let me just run this and see what happens" moments, it's hard to beat.
Follow @githubprojects for more developer tools and open source projects.