Exploring Scalar as a Modern Alternative to Swagger for .NET APIs
Recently, I’ve been exploring different API documentation tooling. While Swagger (Swashbuckle) has long been the standard for OpenAPI documentation in .NET, I discovered an interesting alternative: Scalar.
This article shares my experience implementing Scalar and why it might be worth considering for your next .NET API project.
What is Scalar?
Scalar is a modern, open-source API documentation tool that generates beautiful, interactive documentation from your OpenAPI specifications. Unlike traditional tools that can feel heavyweight, Scalar takes a streamlined approach with an emphasis on:
- Developer experience - Clean, intuitive interface for exploring and testing APIs
- Modern design - Responsive UI that looks great out of the box
- Performance - Fast, lightweight client that doesn’t bog down your development workflow
- Simplicity - Minimal configuration required to get started
Why Consider Scalar Over Swagger?
Don’t get me wrong - Swagger/Swashbuckle is battle-tested and works great. But here’s why Scalar caught my attention:
1. Modern UI/UX
Scalar’s interface feels contemporary and polished. It’s designed with modern web standards and provides a cleaner, more intuitive experience than the classic Swagger UI.
2. Minimal API Alignment
With .NET’s shift toward minimal APIs, Scalar’s lightweight philosophy feels like a natural fit. It embraces simplicity without sacrificing functionality.
3. Better Developer Experience
Scalar provides features like:
- Three-panel layout (documentation, request, response)
- Dark mode support
- Better syntax highlighting
- More intuitive request testing
- Improved search and navigation
4. Zero Config to Get Started
While Swagger requires some boilerplate setup, Scalar works with minimal configuration while still offering deep customization when you need it.
5. Active Development
Scalar is being actively developed with modern web technologies, which means regular updates and improvements.
Setting Up Scalar in Your .NET Project
Getting started with Scalar is straightforward. Here’s a step-by-step guide:
1. Install the Package
Add the Scalar NuGet package to your project:
| |
2. Configure in Program.cs
Here’s a minimal setup that gets you up and running:
Note for .NET 9+:
AddEndpointsApiExplorer()is no longer required when using the built-inAddOpenApi(). It’s included here for compatibility with older versions.
| |
3. Explore Your API
Run your application and navigate to /scalar/v1 (or your configured endpoint). You’ll see Scalar’s documentation UI where you can view, test, and interact with your APIs.
Advanced Configuration
Scalar offers extensive customization options. Here are some common scenarios:
Customize the UI Path
Change where Scalar is hosted:
| |
Configure Metadata, Branding, and Themes
Customize the appearance, metadata, and theming in a single options block:
| |
Add Authentication Configuration
Configure authentication for testing endpoints directly in the UI:
| |
Organize with Tags
Use tags to group related endpoints:
| |
Exclude Endpoints from Documentation
Keep internal endpoints out of your documentation:
| |
Key Features Worth Calling Out
Here are a few capabilities that go beyond the basics and genuinely change how you work with the docs day-to-day:
1. Client Code Generation
Scalar can generate ready-to-use request code directly from the UI across a wide range of targets - C#, JavaScript/TypeScript, Python, Go, Java, Shell (curl/wget), and more. This is particularly useful when onboarding frontend developers or third-party consumers: instead of walking them through how to call an endpoint, you hand them working code.
2. Deep Linking to Endpoints
Every endpoint in Scalar has a stable, shareable URL. In practice this means you can paste a link directly to POST /api/orders in a Slack message or PR description and your colleague lands exactly there - no scrolling through a wall of endpoints. Sounds minor, but it noticeably reduces friction in code reviews and API design discussions.
3. Markdown in Descriptions
You can use full Markdown in WithDescription() and WithSummary() calls, including code blocks, tables, and links. This lets you embed usage notes, deprecation warnings, or example payloads right alongside the endpoint - keeping documentation close to the code rather than in a separate wiki that inevitably goes stale.
4. Downloadable OpenAPI Spec
The UI exposes a direct link to download the raw OpenAPI JSON/YAML. This is handy when you want to import the spec into Postman, share it with a consumer generating their own client, or feed it into an API gateway configuration.
5. Environment/Server Switching
If your OpenAPI document defines multiple servers (e.g. localhost, staging, production), Scalar surfaces a server selector in the UI. This lets you point the request builder at different environments without leaving the documentation tab - useful for quickly sanity-checking a staging deployment.
When to Use Scalar vs. Swagger
Choose Scalar if:
- You’re building a new API and want a modern documentation experience
- Developer experience and UI/UX are priorities
- You prefer minimal configuration
- You’re working with minimal APIs
Stick with Swagger if:
- You have existing Swagger/Swashbuckle implementations
- Your team is already familiar with Swagger tooling
- You need specific Swagger ecosystem integrations
- You require features unique to Swashbuckle
Real-World Example
Here’s a more complete example showing Scalar in a realistic API:
| |
Final Thoughts
I think that Scalar should become a go-to choice for new .NET API projects. Its modern interface, minimal configuration, and excellent developer experience make API documentation feel less like a chore and more like a natural part of the development process.
That said, there’s no one-size-fits-all solution. If you’re maintaining existing projects with Swagger, there’s no urgent need to switch. But for greenfield projects or if you’re curious about trying something new, I’d recommend giving Scalar a go.
Resources: