• Stars
  • Rank 86,011 (Top 2 %)
  • Language
  • License
    MIT License
  • Created over 9 years ago
  • Updated 3 months ago


There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

High performance CSV reader and writer for Java.


FastCSV is an ultra-fast, dependency-free and RFC-compliant CSV library for Java.

build Codacy Badge codecov javadoc Maven Central

The primary use cases of FastCSV are:

  • in big data applications: read and write data on a massive scale
  • in small data applications: a lightweight library without any further dependencies

Benchmark & Compatibility

A selected benchmark from the Java CSV library benchmark suite project:


While maintaining high performance, FastCSV is a strict RFC 4180 CSV writer but also able to read garbled CSV data (to some degree). See JavaCsvComparison for details.


Library specific

  • Ultra fast
  • Small footprint
  • Zero runtime dependencies
  • Null-free
  • Works with GraalVM Native Image
  • OSGi capable

CSV specific

  • Compliant to RFC 4180 โ€“ including:
    • Newline and field separator characters in fields
    • Quote escaping
  • Configurable field separator
  • Support for line endings CRLF (Windows), CR (old macOS) and LF (Unix)
  • Unicode support

Reader specific

  • Support reading of some non-compliant (real world) data
  • Preserving line break character(s) within fields
  • Preserving the starting line number (even with skipped and multi line records) โ€“ helpful for error messages
  • Auto-detection of line delimiters (can also be mixed)
  • Configurable data validation
  • Support for (optional) header records (get field based on field name)
  • Support for skipping empty records
  • Support for commented lines (skipping & reading) and configurable comment character
  • BOM support (UTF-8, UTF-16 and UTF-32 with little- or big-endian)

Writer specific

  • Support for multiple quote strategies to differentiate between empty and null
  • Support for writing comments with proper quotation if needed


  • for 3.x version: Java 11 (Android 13 / API level 33)
  • for 2.x version: Java 8 (Android 8 / API level 26)

๐Ÿ’ก Android is not Java and is not officially supported. Although some basic checks are included in the continuous integration pipeline in order to verify that the library should work with Android.

CsvReader Examples

Iterative reading of some CSV data from a string


Iterative reading of a CSV file

try (CsvReader csv = CsvReader.builder().build(path)) {

Custom settings


For more examples see CsvReaderExample.java

NamedCsvReader Examples

Iterative reading of some CSV data with a header

CsvReader csvReader = CsvReader.builder().build("header 1,header 2\nfield 1,field 2");
    .forEach(csvRecord -> System.out.println(csvRecord.getField("header 2")));

Iterative reading of some CSV data with a custom header

List<String> header = List.of("header 1", "header 2");
CsvReader csvReader = CsvReader.builder().build("field 1,field 2");
    .forEach(csvRecord -> System.out.println(csvRecord.getField("header 2")));

For more examples see NamedCsvReaderExample.java

IndexedCsvReader Examples

Indexed reading of a CSV file

try (IndexedCsvReader csv = IndexedCsvReader.builder().build(file)) {
    CsvIndex index = csv.index();

    System.out.println("Items of last page:");
    int lastPage = index.pageCount() - 1;
    List<CsvRecord> csvRecords = csv.readPage(lastPage);

For more examples see IndexedCsvReaderExample.java

CsvWriter Examples

Iterative writing of some data to a writer

var sw = new StringWriter();
    .writeRecord("header1", "header2")
    .writeRecord("value1", "value2");


Iterative writing of a CSV file

try (CsvWriter csv = CsvWriter.builder().build(path)) {
        .writeRecord("header1", "header2")
        .writeRecord("value1", "value2");

Custom settings


For more examples see CsvWriterExample.java.

Upgrading from an older version

Please see UPGRADING.md for a list of breaking changes in version 3 and how to upgrade.

Sponsoring and partnerships


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.