pointfreeco /swift-parsing

A library for turning nebulous data into well-structured data, with a focus on composition, performance, generality, and ergonomics.

★ 1,001⑂ 95👁 14⑃ 202● 59▤ 27
SwiftMITCreated 2020-12-21www.pointfree.co/collections/parsing
Download: 0.15.30.15.3 ↓0.15.32026-11-23
+0
Daily
1,001
stars
95
forks
14
watchers
202
prs
59
issues
27
releases

README

swift-parsing


!CI




A library for turning unstructured data into structured data, with a focus on composition, performance, generality, and invertibility:

 Composition: Ability to break large, complex parsing problems down into smaller, simpler ones. And the ability to take small, simple parsers and easily combine them into larger, more complex ones.

 Performance: Parsers that have been composed of many smaller parts should perform as well as highly-tuned, hand-written parsers.

 Generality: Ability to parse _any_ kind of input into _any_ kind of output. This allows you to choose which abstraction levels you want to work on based on how much performance you need or how much correctness you want guaranteed. For example, you can write a highly tuned parser on collections of UTF-8 code units, and it will automatically plug into parsers of strings, arrays, unsafe buffer pointers and more.

 Invertibility: Ability to invert your parsers so that they are printers. This allows you to transform your well-structured data back into unstructured data, which is useful for serialization, sending data over the network, [URL routing][swift-url-routing], and more.

---

 Motivation
 Getting started
 Benchmarks
 Documentation
 Community
 Other libraries
 License

 Learn More

This library was designed over the course of many episodes on Point-Free, a video series exploring functional programming and the Swift language, hosted by Brandon Williams and Stephen Celis. You can watch all of the episodes here.


  


 Motivation

Parsing is a surprisingly ubiquitous problem in programming. We can define parsing as trying to transform unstructured data into structured data. The Swift standard library comes with a number of parsers that we reach for every day. For example, there are initializers on Int, Double, and even Bool, that attempt to parse numbers and booleans from strings:

swift
Int("42")          // 42
Int("Hello")       // nil

Double("123.45")   // 123.45
Double("Goodbye")  // nil

Bool("true")       // true
Bool("0")          // nil


And there are types like JSONDecoder and PropertyListDecoder that attempt to parse Decodable-conforming types from data:

swift
try JSONDecoder().decode(User.self, from: data)
try PropertyListDecoder().decode(Settings.self, from: data)


While parsers are everywhere in Swift, Swift has no holistic story _for_ parsing. Instead, we typically parse data in an ad hoc fashion using a number of unrelated initializers, methods, and other means. And this typically leads to less maintainable, less reusable code.

This library aims to write such a story for parsing in Swift. It introduces a single unit of parsing that can be combined in interesting ways to form large, complex parsers that can tackle the programming problems you need to solve in a maintainable way.

 Getting started

 This is an abridged version of the ["Getting Started"][getting-started-docs] article in the library's [documentation][swift-parsing-docs].

Suppose yo

Top issues

Discussions

Latest release

0.15.3 0.15.3 2026-11-23
What's Changed
 Update supported platforms for Swift 6.4. @bunoza in https://github.com/pointfreeco/swift-parsing/pull/401

 New Contributors
 @bunoza made their first contribution in https://github.com/pointfreeco/swift-parsing/pull/401

Full Changelog: https://github.com/pointfreeco/swift-parsing/compare/0.15.2...0.15.3

Snapshot: 2026-11-27T22:26:53Z · Data license Apache-2.0 · JSON