Back to Scalar

API Reference vs. Swagger UI

documentation/migration/swagger-ui.md

latest14.8 KB
Original Source

API Reference vs. Swagger UI

Swagger UI used to be the most widely used tool for rendering OpenAPI documentation. It has been around since 2011 and has a massive ecosystem. API Reference is a modern alternative that offers a more polished developer experience while remaining fully compatible with your existing OpenAPI documents.

When you migrate to Scalar, you unlock additional tools to enhance your API workflow:

  • A modern, open-source API testing client, embedded in your API reference
  • Instant search functionality built-in

Why Migrate?

Modern UI/UX

Scalar offers a cleaner, more intuitive interface with a modern design that looks great out of the box. The UI is responsive, supports dark mode, and provides better navigation for large APIs.

Better Performance

Scalar is built with modern web technologies and optimized for performance. Large OpenAPI documents render faster and the interface remains smooth even with hundreds of endpoints.

Interactive API Client

While Swagger UI has "Try it out" functionality, Scalar's built-in API client is more powerful—supporting environment variables, request history, code snippet generation in 25+ languages, and a standalone desktop application (optional).

Extensive Customization

Scalar offers 11 built-in themes and extensive CSS customization options. You can style everything from colors and fonts to sidebar layouts and component spacing.

Feature Comparison

FeatureScalarSwagger UI
Core Features
OpenAPI 3.0 Support
OpenAPI 3.1 Support
OpenAPI 3.1.2 Support
OpenAPI 3.2 Supportin progressnot in sight
Swagger 2.0 Support
Try It Out / Test Requestssimple implementation
Multiple Documents
User Interface
Modern Layout
Classic (Swagger-style) Layout
Dark Mode
Built-in Themes11 themes
Custom CSS Support
Sidebar Navigation
Searchplugin required
Code Snippets
Code Snippet Generation25+ languageslimited
Custom Code Examples
Authentication
OAuth 2.0 Support
API Key Support
Persist Auth Credentials
Pre-fill Auth Credentialsthrough hooks
Integrations
React Component
Vue Component
Advanced Features
CORS Proxy
Quick Share
Desktop API Client
Community
PRs merged (2025)2,075176
Discorddiscord.gg/scalar

Migrate from Swagger UI to Scalar

Migration is straightforward. In most cases, you can swap out Swagger UI for Scalar in minutes while keeping your existing OpenAPI document unchanged.

Basic HTML Migration

Swagger UI

html
<!doctype html>
<html>
  <head>
    <title>Swagger UI</title>
    <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist/swagger-ui.css" />
  </head>
  <body>
    <div id="swagger-ui"></div>
    <script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
    <script>
      SwaggerUIBundle({
        url: '/openapi.json',
        dom_id: '#swagger-ui',
      })
    </script>
  </body>
</html>

API Reference

html
<!doctype html>
<html>
  <head>
    <title>API Reference</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body>
    <div id="app"></div>
    <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
    <script>
      Scalar.createApiReference('#app', {
        url: '/openapi.json',
      })
    </script>
  </body>
</html>

Configuration Mapping

Here's how common Swagger UI options map to Scalar:

Swagger UIScalar
urlurl
speccontent
urlssources
dom_idFirst argument to createApiReference()
deepLinkingEnabled by default
displayOperationIdshowOperationId: true
defaultModelsExpandDepth: -1hideModels: true
defaultModelExpandDepthexpandAllModelSections: true
docExpansion: 'none'defaultOpenAllTags: false (default)
docExpansion: 'list'defaultOpenAllTags: false (default)
docExpansion: 'full'defaultOpenAllTags: true
filterSearch enabled by default
filter: falsehideSearch: true
tryItOutEnabledEnabled by default
supportedSubmitMethods: []hideTestRequestButton: true
operationsSorter: 'alpha'operationsSorter: 'alpha'
operationsSorter: 'method'operationsSorter: 'method'
tagsSorter: 'alpha'tagsSorter: 'alpha'
persistAuthorizationpersistAuth: true

Integrations

You can use one of our many integrations for basically any programming language and framework.

Theme and Styling

Using a Classic Layout

If you prefer the traditional Swagger UI layout, Scalar offers a classic layout option, that is not too different:

javascript
Scalar.createApiReference('#app', {
  url: '/openapi.json',
  layout: 'classic',
})

Built-in Themes

Scalar includes built-in themes:

  • default
  • alternate
  • moon
  • purple
  • solarized
  • bluePlanet
  • saturn
  • kepler
  • mars
  • deepSpace
  • laserwave
javascript
Scalar.createApiReference('#app', {
  url: '/openapi.json',
  theme: 'moon',
})

Custom Styling

Override CSS variables to match your brand:

html
<style>
  :root {
    --scalar-font: 'Your Font', sans-serif;
    --scalar-color-accent: #0a85d1;
  }
  .dark-mode {
    --scalar-background-1: #1a1a1a;
    --scalar-color-1: rgba(255, 255, 255, 0.9);
  }
  .light-mode {
    --scalar-background-1: #ffffff;
    --scalar-color-1: #121212;
  }
</style>

Additional Scalar Features

These features have no Swagger UI equivalent:

FeatureDescription
proxyUrlAvoid CORS issues with a proxy server
hiddenClientsControl which code snippet languages are shown
defaultHttpClientSet the default code snippet language
searchHotKeyCustomize the keyboard shortcut for search
baseServerURLPrefix all relative server URLs
pathRoutingUse path-based routing instead of hash-based
onBeforeRequestModify requests before they are sent
authenticationPre-fill authentication credentials