---
title: "dprint: The Rust-Based Code Formatter That's 10-100x Faster Than Prettier"
description: "Prettier is slow and bloated. dprint is a Rust-based alternative that's 10-100x faster with zero npm dependencies. Here's why I switched."
date: 2025-11-18
slug: "dprint-rust-based-code-formatter-faster-prettier"
tags: ["tools", "rust", "prettier", "formatting", "performance", "devtools"]
---

I want to talk about code formatters. Prettier has been the standard for years. It's everywhere. But it's also slow and pulls in a ton of dependencies.

I switched to dprint for my latest project and I'm not going back. It's 10-100x faster, has zero npm dependencies, and the formatting quality is basically identical to Prettier.

## The Prettier Problem

Don't get me wrong, Prettier is great. Automatic code formatting changed how we write code. No more arguing about semicolons or bracket placement. Just format on save and move on.

But Prettier has issues at scale:

**Slow**: Large codebases take seconds to format. That adds up when you're formatting on every save or in pre-commit hooks.

**Dependencies**: Prettier pulls in ~20MB of npm dependencies. For a formatting tool, that's heavy.

**Node-only**: It's JavaScript, so it needs Node. Can't use it in non-Node environments without extra setup.

For small projects, these issues don't matter. But when you're formatting hundreds of files or running it in CI/CD pipelines repeatedly, the slowness becomes painful.

## Enter dprint

dprint is a code formatter written in Rust. It compiles to a native binary. No npm dependencies, just a standalone executable.

**The speed difference is dramatic.** Prettier takes 2-3 seconds to format my newsletter digester project. dprint does it in 50-100ms. That's 20-60x faster.

On larger codebases the gap is even wider. I've seen dprint complete in under 200ms on projects where Prettier takes 10+ seconds.

## Zero Dependencies

This is my favorite part. dprint downloads a standalone binary. That's it. No node_modules bloat, no dependency tree to manage.

Your package.json stays clean:

```json
{
  "devDependencies": {
    "dprint": "^0.45.0"
  }
}
```

Compare that to Prettier which pulls in dozens of transitive dependencies. With dprint, you get one ~15MB binary that just works.

## Setup is Simple

Install it:

```bash
npm install -D dprint
```

Create `dprint.json` in your project root:

```json
{
  "incremental": true,
  "javascript": {
    "quoteStyle": "single",
    "semiColons": "always",
    "lineWidth": 100,
    "indentWidth": 2
  },
  "json": {
    "indentWidth": 2
  },
  "includes": ["src/**/*.js", "*.{json,md}"],
  "excludes": ["node_modules", "dist"],
  "plugins": [
    "https://plugins.dprint.dev/json-0.19.2.wasm",
    "https://plugins.dprint.dev/markdown-0.16.3.wasm"
  ]
}
```

Add scripts to package.json:

```json
{
  "scripts": {
    "format": "dprint fmt",
    "format:check": "dprint check"
  }
}
```

That's it. Run `npm run format` and you're done.

## Real-World Performance

Here are actual numbers from my newsletter digester project:

**Prettier**:

- Format all files: ~2.3 seconds
- Dependencies: 20MB+ in node_modules
- First run (no cache): ~3 seconds

**dprint**:

- Format all files: ~75ms
- Dependencies: 0 (15MB binary)
- First run (no cache): ~95ms

The difference is immediately noticeable. Format on save feels instant instead of having that slight pause while Prettier thinks about it.

## Pre-commit Hooks

This speed really shines in pre-commit hooks. With Prettier, formatting all staged files could take 1-2 seconds. Not terrible, but noticeable.

With dprint, the entire pre-commit hook (format + tests) runs in under a second. The formatting itself takes ~100ms, so you barely notice it.

My pre-commit setup:

```json
{
  "scripts": {
    "pre-commit": "dprint fmt && npm test"
  }
}
```

Using Husky to run it:

```bash
#!/usr/bin/env sh
npm run pre-commit
```

Total time: ~600ms (100ms format + 500ms tests). Commits feel instant.

## Format Quality

The actual formatting is basically identical to Prettier. I compared the output on my entire project and found zero meaningful differences.

dprint follows the same principles: opinionated, consistent, minimal configuration. It produces clean, readable code that looks exactly like what you'd expect from Prettier.

## What About Biome?

Biome is another Rust-based formatter (and linter) that's blazing fast. It's excellent and worth considering.

I chose dprint because:

- Simpler configuration
- Pure formatter (I use ESLint for linting)
- Slightly smaller binary
- Established plugin ecosystem

Biome is great if you want an all-in-one formatter + linter. dprint is better if you want a focused, fast formatter that does one thing well.

## Editor Integration

VS Code has a dprint extension. Install it and add to your `.vscode/settings.json`:

```json
{
  "editor.defaultFormatter": "dprint.dprint",
  "editor.formatOnSave": true
}
```

WebStorm, Vim, Neovim, and Sublime all have integrations too. Format on save works everywhere.

## Should You Switch?

If you're running Prettier on small projects and it feels fast enough, stick with Prettier. The ecosystem is mature and well-supported.

Switch to dprint if:

- You have a large codebase where Prettier feels slow
- You run formatting in CI/CD and want faster builds
- You want to minimize npm dependencies
- You care about pre-commit hook performance
- You're building something where every millisecond matters

For me, the speed improvement alone was worth it. Going from 2-3 seconds to under 100ms makes formatting feel invisible. That's how it should be.

## Try It

The code for my newsletter digester (where I use dprint) is on GitHub: [github.com/mfyz/newsletter-blog-digester](https://github.com/mfyz/newsletter-blog-digester)

Clone it, run `npm install`, then `npm run format`. You'll see the speed difference immediately.

dprint proved that you don't need to compromise between speed and quality. A well-designed Rust binary can do both.
