Skip to content

FastCSV: Fast CSV Library for Java

FastCSV is a high-performance CSV parser and writer for Java licensed under the MIT open source license. It is designed to not only be fast and lightweight but also to be compliant with the CSV specification RFC 4180.

Benchmark

This selected benchmark is based on the Java CSV library benchmark suite.

Reading and writing perfectly formatted CSV data is straightforward. However, real-world CSV data is often not perfectly formatted. See Java Csv Comparison Project on how CSV libraries handle real-world CSV data and how FastCSV compares to other libraries.

The primary use cases are:

  • In big data applications: efficiently reading and writing data on a massive scale.
  • In small data applications: serving as a lightweight library without additional dependencies.

The main features of FastCSV include:

  • Enables ultra-fast reading and writing of CSV data
  • Has zero runtime dependencies
  • Maintains a small footprint
  • Provides a null-free and developer-friendly API
  • Compatible with GraalVM Native Image
  • Delivered as an OSGi-compliant bundle
  • Actively developed and maintained
  • Well-tested and documented
  • Crafted with natural intelligence, ❤️, and AI assistance ✨
  • Compliant with RFC 4180 – including:
    • Line breaks and field separators in fields
    • Escape pairs ("") in quoted fields
  • Configurable field separator
  • Supports line breaks CRLF (Windows), LF (Unix) and CR (old macOS)
  • Supports unicode characters
  • Tolerates some malformed (real-world) CSV data
  • Preserves line break character(s) within fields
  • Preserves the starting line number (even with skipped and multi-line records) – helpful for error messages
  • Recognizes all line breaks (CRLF, LF, or CR – can also be mixed)
  • Configurable data validation
  • Supports single and multi-character field separators
  • Supports trimming whitespace around quoted fields
  • Supports an optional header (access fields by field name)
  • Supports duplicate field names
  • Supports skipping empty lines
  • Supports skipping lines before the CSV data (either by a fixed number of lines or by peeking data)
  • Supports comments (skipping & reading) with configurable comment character
  • Configurable field modifiers (e.g., to trim fields)
  • Flexible callback handlers (e.g., to directly map to domain objects)
  • BOM (Byte Order Mark) support (UTF-8, UTF-16 LE/BE, UTF-32 LE/BE)
  • Supports flexible quoting strategies (e.g., to differentiate between empty and null)
  • Supports writing comments
  • for 4.x version: Java ⩾ 17 (Android 14 / API level 34)
  • for 3.x version: Java ⩾ 11 (Android 13 / API level 33)
  • for 2.x version: Java ⩾ 8 (Android 8 / API level 26)

This documentation is based on the latest version of FastCSV (4.x). For older versions, please refer to the respective Git branches.

FastCSV is trusted by many open source projects, including:

  • Apache NiFi — “Easy to use, powerful, and reliable system to process and distribute data”
  • JPMML — “Java implementation of the Predictive Model Markup Language”
  • JUnit — “The programmer-friendly testing framework for Java and the JVM”
  • Karate — “The only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework”
  • Neo4j — “World’s most-loved graph database”

YourKit

YourKit was used to optimize the performance and footprint of FastCSV. YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler, and YourKit YouMonitor.