Join the chat at Travis CI

atto is a compact, pure-functional, incremental text parsing library for Scala. The API is non-invasive (nothing to extend!) and uses sensible and familiar abstractions. atto parsers are a fun and principled tool for everyday parsing.

scala> import atto._, Atto._
import atto._
import Atto._

scala> int.sepBy(spaceChar).parseOnly("1 20 300").option
res0: Option[List[Int]] = Some(List(1, 20, 300))

The current version is 0.7.0 for Scala 2.11/12/13 and Scala-JS (2.11+) with cats 2.0.0. Add it to your build.sbt thus:

libraryDependencies += "org.tpolecat" %% "atto-core"    % "0.7.0"
libraryDependencies += "org.tpolecat" %% "atto-refined" % "0.7.0"

More information on atto-refined in the dedicated guide which provides an integration with refined 0.9.9.

Documentation and Support

Why atto?

atto differs from stdlib parser combinators in a number of ways:

  • You don’t have to extend a trait or implement any methods.
  • There is no tokenizer; the input type is always Char.
  • Abstractions are better defined, which leads to simpler, more general code. Parser is a cats Monad for example, which gives us a lot of helpful operations for free.
  • Parsers are incremental which means you can evaluate whether a prefix of your input is “ok so far.” This can be helpful when working with streams or interactive UIs.

It’s not a big deal to construct and use atto parsers; use them in any situation where you might otherwise reach for regular expressions or raw string manipulation.

Although atto is 50 times faster now than version 0.1, it’s still not the fastest parsing lib on the block. If you’re doing massive data processing you might look at a library like Fastparse, or even a hand-built parser like those used in the fastest JSON libs. But for “everyday” parsing where you have to turn user input into something useful, atto is a friendly little library to use.


The core of atto originated in Edward Kmett’s Scala port of Attoparsec. This library is an elaboration maintained by @tpolecat with contributions from some very helpful folks. Feedback and suggestions are always welcome.


Attoparsec, a Haskell library, is licensed under BSD-3 as specified here; the derivative work atto is provided under the MIT licence here. Both licenses appear in project metadata.