OSS TanbouSign in with GitHub

format and lint Swift source with shared rules across CLI, Xcode, SwiftPM, and CI

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
8,928
Primary language
Swift
License
MIT
Repository last updated
Oct 6, 2026
On this page

Overview

SwiftFormat is a Swift code-formatting library and CLI. Beyond whitespace, its rules can normalize implicit self, redundant parentheses, and many Swift idioms, while .swiftformat, lint mode, Xcode integration, SwiftPM plugins, and CI workflows automate a shared code style.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Pin formatting rules and options in .swiftformat

swiftformat . applies formatting rules to Swift files under a directory, while .swiftformat stores indentation, Swift-version, and rule configuration per project. --infer-options can suggest options based on existing source style.

Sources: [2]

Reuse the same rules in lint mode, SwiftPM plugins, and GitHub Actions

The formatter can run as --lint, through a SwiftPM command plugin, Xcode build phase, pre-commit hook, or GitHub Actions workflow so local and CI enforcement use the same configuration.

Sources: [2][3]

Best fit

Fits Swift teams that want less style noise and more behavior-focused code review

It is useful when spacing, declaration layout, and other style differences should be automated and formatting violations should be caught in CI.

Sources: [2]

Before adoption

Formatting rewrites source files, so pin the version and inspect diffs

The README warns that swiftformat . overwrites matching Swift files and recommends consistent tool versions for shared projects. Version 0.63.1 adds deterministic sorting through --locale and multiple rule fixes; Package.swift uses Swift tools 5.7.

Sources: [2][4][3]

Official sources

  1. [1]nicklockwood/SwiftFormat — GitHub repository(2026-10-06)
  2. [2]SwiftFormat 0.63.1 — README(2026-10-06)
  3. [3]SwiftFormat 0.63.1 — Package.swift(2026-10-06)
  4. [4]SwiftFormat 0.63.1 release(2026-10-06)
  5. [5]SwiftFormat MIT license(2026-10-06)
Supplemental curator note

SwiftFormat fits teams that want automated Swift style and less formatting noise in review. Because formatting rewrites source files, pin the version, keep changes under source control, and use lint mode in CI.

Try it in 3 steps

  1. 1

    Add SwiftFormat 0.63.1 as a SwiftPM dependency

    Pin the formatter version used by the project and make SwiftFormatPlugin available.

    .package(url: "https://github.com/nicklockwood/SwiftFormat", exact: "0.63.1")
  2. 2

    Define project rules in .swiftformat

    Store the Swift version and indentation rules in the project-root configuration.

    printf "%s\n" "--swiftversion 6.0" "--indent 2" > .swiftformat
  3. 3

    Run formatting through the SwiftPM plugin

    Apply the formatter using .swiftformat. Commit or stash source changes first because formatting rewrites files.

    swift package plugin --allow-writing-to-package-directory swiftformat
Check the official README

Growth

Growth trends · Last 30 days

8,928 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
18
Open PRs
6

Development activity is still being collected.

Built with

Categories and tags

GitHub data

GitHub dataView detailed GitHub data
Stars
8,928
Forks
708
Watchers
75
Open issues
288
Contributors
191
Owner type
User
Primary language
Swift
License
MIT
Repository last updated
Oct 6, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?