Introduction
When starting a new Node.js project, Express is often the first framework developers consider.
It's simple, popular, and easy to use. I have also used Express because it makes backend development straightforward.
But for my new project, I decided to try Fastify instead of Express.
Why?
I wanted better built-in validation, organized code, useful logging, and good performance without adding too many extra packages.
Let's look at why Fastify was the right choice for this project.
What Is Express.js?
Express.js is a lightweight web framework for Node.js.
It helps developers build websites, REST APIs, and backend applications quickly.
Why developers use Express
- Easy to learn and set up.
- Large community and ecosystem.
- Flexible middleware system.
- Suitable for small and large applications.
- Works with JavaScript and TypeScript.
Express is still a great framework, especially for developers who want simplicity and flexibility.
What Is Fastify?
Fastify is a web framework for Node.js designed for performance and developer productivity.
Like Express, it helps developers create APIs and backend applications.
However, Fastify provides several useful features as part of its framework design.
Key features of Fastify
- High-performance request handling.
- Built-in schema-based validation.
- Structured logging through Pino.
- Plugin-based architecture.
- TypeScript support.
- Schema-based response serialization.
These features make Fastify attractive for developers building structured, maintainable APIs.
Fastify vs Express: Quick Comparison

| Feature | Express.js | Fastify |
|---|---|---|
| Performance | Good | Typically faster in framework benchmarks |
| Learning curve | Very easy | Easy, with some new concepts |
| Request validation | External libraries | Built-in schema support |
| Logging | Middleware or packages | Built-in Pino integration |
| Architecture | Flexible middleware | Plugin-based |
| TypeScript | Supported | Supported |
| Community | Very large | Smaller but established |
| Best for | General-purpose APIs | Structured, performance-focused APIs |
Both frameworks are capable of building production applications. The best choice depends on your project.
1. Fastify Offers Good Performance

Performance was one reason I considered Fastify.
Fastify is designed to handle requests efficiently, with optimized routing and JSON serialization.
For an API receiving many requests, reducing framework overhead can help.
Why it matters:
- Efficient HTTP request handling.
- Optimized response serialization.
- Useful foundation for high-traffic APIs.
However, performance depends on many factors, including database queries, server resources, and application code.
Fastify does not automatically make every application faster.
2. Built-In Validation Makes APIs Cleaner

This was one of my favorite Fastify features.
In Express, developers often install libraries such as Zod or Joi to validate incoming data.
Fastify supports JSON Schema validation directly in its route definitions.
Fastify example
fastify.post('/users', {
schema: {
body: {
type: 'object',
required: ['name'],
properties: {
name: { type: 'string' }
}
}
}
}, async (request) => {
return { message: 'User created' };
});
Fastify checks whether the incoming data matches the defined schema before executing the handler.
Benefits:
- Less repetitive validation code.
- Clear request requirements.
- Automatic validation errors.
- Easier API maintenance.
The example shows input validation, not actual database creation.
3. Fastify Helps Organize Large Projects

As backend projects grow, keeping code organized becomes important.
Fastify uses a plugin-based architecture.
Developers can separate application features into different modules.
For example:
src/
plugins/
database.js
auth.js
routes/
users.js
products.js
app.js
This makes it easier to manage features such as authentication, database connections, and API routes.
Express can also use a similar structure, but Fastify's plugin system provides additional encapsulation features.
4. Built-In Logging Saves Setup Time
Logging helps developers understand what happens inside an application.
In Express, developers typically configure a logging library or middleware.
Fastify includes integration with Pino.
Example
import Fastify from 'fastify';
const app = Fastify({
logger: true
});
That's enough to enable structured application logging.
Why I liked it:
- Quick setup.
- Structured logs.
- Easier request tracking.
- Helpful for debugging production issues.
Good logging becomes increasingly important as applications grow.
5. Fastify Works Well With TypeScript
TypeScript helps catch many coding mistakes during development.
Fastify provides TypeScript definitions and supports typed routes, request data, and application extensions.
For my new project, this was another useful advantage.
It helps make backend code easier to understand and maintain.
Express also supports TypeScript, so this isn't an exclusive Fastify feature.
When Should You Choose Express?
Fastify isn't always the better option.
Express can be a great choice when:
- You're learning Node.js backend development.
- You're building a simple REST API.
- Your team already uses Express.
- Your project depends on Express-specific middleware.
- You want maximum flexibility.
If an existing Express application works well, switching frameworks may create unnecessary work.
When Should You Choose Fastify?
Fastify is worth considering when:
- You're starting a new backend project.
- You want schema-based validation.
- You prefer a plugin-based structure.
- You need structured logging.
- You want to reduce framework overhead.
- You're building an API expected to grow.
Fastify offers a useful starting point for these requirements.
Final Verdict: Why I Picked Fastify
For my project, the decision wasn't only about performance.
I wanted a backend framework that provided important features without requiring too much additional setup.
Fastify gave me:
- Built-in validation.
- Structured logging.
- Modular plugin architecture.
- Performance-focused request handling.
- Good TypeScript support.
Express can deliver many of these benefits with additional libraries and configuration.
But Fastify matched the way I wanted to organize this new project.
My takeaway: Express is excellent for flexibility. Fastify is a strong option when you want a more structured API development experience from the beginning.
Neither framework is perfect for every project.
Choose based on your application's requirements, your team's experience, and the tools you actually need.
Planning a fast, well-structured Node.js backend?
Explore our Software Development services or book a call to discuss your project.
Frequently Asked Questions (FAQs)
Conclusion
I chose Fastify over Express because it offered the features I wanted for a new Node.js backend with less initial configuration.
Express remains a reliable option, but Fastify's validation, architecture, and logging made it a better fit for this particular project.
The best backend framework isn't always the fastest one. It's the one that helps your team build and maintain the application effectively.

