Fast, compact, strict and lazy byte strings with a list interface

Version on this page:
LTS Haskell 22.30:
Stackage Nightly 2024-07-24:
Latest on Hackage:

See all snapshots bytestring appears in

BSD-3-Clause licensed by Don Stewart, Duncan Coutts
Maintained by Haskell Bytestring Team, Core Libraries Committee
This version can be pinned in stack with:bytestring-,7595

ByteString: Fast, Packed Strings of Bytes

Build Status Hackage Stackage LTS Stackage Nightly

This library provides the Data.ByteString module – strict and lazy byte arrays manipulable as strings – providing very time/space-efficient string and IO operations.

For very large data requirements, or constraints on heap size, Data.ByteString.Lazy is provided, a lazy list of bytestring chunks. Efficient processing of multi-gigabyte data can be achieved this way.

The library also provides Data.ByteString.Builder for efficient construction of ByteString values from smaller pieces during binary serialization.


  • Cabal 1.10 or greater
  • GHC 8.0 or greater


ByteString was derived from the GHC PackedString library, originally written by Bryan O’Sullivan, and then by Simon Marlow. It was adapted and greatly extended for darcs by David Roundy and others. Don Stewart and Duncan Coutts cleaned up and further extended the implementation and added the .Lazy code. Simon Meier contributed the Builder feature.

Changes — October 2023 — August 2023 — August 2023 — July 2023 — January 2023 — May 2022 — February 2022

Erratum: unsafeIndex was accidentally removed from the export list of Data.ByteString.Short.Internal in this release. This was corrected in — December 2021 — February 2021 – January 2021 — September 2020 – August 2020 – June 2020

  • Fix off-by-one infinite loop in primMapByteStringBounded (#203)
  • Don’t perform unaligned writes when it isn’t known to be safe (#133)
  • Improve the performance of sconcat for lazy and strict bytestrings (#142)
  • Document inadvertent behaviour change in findSubstrings
  • Fix benchmark builds (#52)
  • Documentation fixes
  • Test fixes July 2019 [email protected] July 2019

  • Build with GHC 8.8, and tests with QC 2.10+
  • Add conversions between ShortByteString and CString (#126)
  • Documentation fixes (#65, #118, #144, #150, #152, #172)
  • Resolve potential copyright issue with test data (#165) Duncan Coutts [email protected] Feb 2017

  • Make readFile work for files with no size like /dev/null
  • Extend the cases in which concat and toStrict can avoid copying data
  • Fix building with ghc-7.0
  • Minor documentation improvements
  • Internal code cleanups Duncan Coutts [email protected] May 2016

  • Fix Builder output on big-endian architectures
  • Fix building with ghc-7.6 and older Duncan Coutts [email protected] May 2016

  • Use Rabin-Karp substring search for breakSubstring and findSubstring
  • Improve the performance of partition for lazy and strict bytestrings
  • Added stripPrefix and stripSuffix for lazy and strict bytestrings
  • Fix building with ghc 8.0 & base 4.9 (Semigroup etc) Duncan Coutts [email protected] Mar 2015

  • Rename inlinePerformIO so people don’t misuse it
  • Fix a corner case in unfoldrN
  • Export isSuffixOf from D.B.Lazy.Char8
  • Add D.B.Lazy.elemIndexEnd
  • Fix readFile for files with incorrectly reported file size
  • Fix for builder performance with ghc 7.10
  • Fix building with ghc 6.12 Duncan Coutts [email protected] Nov 2014

  • Fix integer overflow in concatenation functions
  • Fix strictness of lazy bytestring foldl’
  • Numerous minor documentation fixes
  • Various testsuite improvements