tree-sitter-swift
Swift grammar for tree-sitter
What it is and what it does
tree-sitter-swift is a language grammar binding that plugs into the tree-sitter incremental parsing framework to parse Swift source code. It generates a syntax tree representation of Swift programs, which can be used for code analysis, transformation, linting, or IDE features. The package provides precompiled wheels for multiple platforms, eliminating the need to build the grammar locally in most cases.
The grammar is maintained actively and designed to work with tree-sitter's core parser engine. It can be used from Python, Rust, JavaScript/Node.js, or WebAssembly environments depending on which tree-sitter binding you pair it with. The package itself contains only the language definition; you supply the tree-sitter parser library separately to actually parse code.
Use it for:
- Build a Swift linter or code quality checker that traverses the syntax tree to detect style violations.
- Implement IDE features like syntax highlighting, code completion, or go-to-definition by querying the parse tree.
- Analyze Swift codebases to extract metrics, find unused code, or refactor patterns across multiple files.
- Create a Swift-to-other-language transpiler or code generator that walks the syntax tree and emits different output.
- Develop a documentation generator that parses Swift source to extract and format API signatures and comments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a tree-sitter grammar for parsing Swift source code, enabling incremental syntax analysis and abstract syntax tree generation.
Yes, if you need to parse Swift code programmatically. The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and provides prebuilt wheels for common platforms. The main caveat is that tree-sitter itself must be available in your environment; verify that dependency is clear before installing.
Install
tree-sitter-swift on PyPI
pip
pip install tree-sitter-swiftuv
uv add tree-sitter-swiftpoetry
poetry add tree-sitter-swiftInstalling tree-sitter-swift
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for common platforms (macOS x86_64/arm64, Linux x86_64/aarch64, Windows x86_64/arm64, musl). Package is actively maintained with recent releases and no known vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package provided you include the license notice.
Quickstart
pip install tree-sitter-swift
import tree_sitter_swift
language = tree_sitter_swift.language()
Python 3.8 or later required; tree-sitter parser library must be available separately in your environment.
Verify before relying
- Whether tree-sitter is automatically installed as a transitive dependency or must be installed separately.
- Performance characteristics when parsing large Swift codebases or in incremental update scenarios.
- Completeness of Swift language coverage across recent Swift versions and all language constructs.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 74 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,943,531/month — #3,415 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tree_sitter_swift-0.7.3-cp38-abi3-macosx_10_9_x86_64.whl; tree_sitter_swift-0.7.3-cp38-abi3-macosx_11_0_arm64.whl; tree_sitter_swift-0.7.3-cp38-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; tree_sitter_swift-0.7.3-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tree_sitter_swift-0.7.3-cp38-abi3-musllinux_1_2_aarch64.whl; tree_sitter_swift-0.7.3-cp38-abi3-musllinux_1_2_x86_64.whl; tree_sitter_swift-0.7.3-cp38-abi3-win_amd64.whl; tree_sitter_swift-0.7.3-cp38-abi3-win_arm64.whl
Keywords: incremental, parsing, tree-sitter, swift
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
tree-sitter-pythonProvides a Python grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-goProvides a Go language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-haskellProvides a tree-sitter parser grammar for…
permissive · top 15,000 on PyPI
tree-sitter-rustProvides a Rust language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-javaProvides a Java language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-rubyProvides a Ruby language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-kotlinProvides a Kotlin language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-phpProvides a PHP language grammar for…
permissive · top 5,000 on PyPI
trailmarkParses source code into a queryable graph of…
permissive · top 15,000 on PyPI