Introduction

🔥 FlameCsv 🔥 is a fully-featured high performance CSV library for .NET with a simple API, deep customization, and built-in support for UTF8, nativeAOT, and more.

FlameCsv can be thought of as a CSV-equivalent of System.Text.Json. It is designed to simple to use, extensible, and performant, while supporting low-level operations for advanced use-cases. FlameCsv is the most memory-efficient .NET CSV library available.

FlameCsv can process millions of CSV records per second on consumer hardware, and write arbitrarily large datasets with near-zero allocations. See the benchmarks for more details.

The library has thousands of unit tests and has been fuzz-tested.

See Getting Started, view the Examples, or deep dive into the API Reference.

Features

  • TL;DR: Blazingly fast, trimmable and easy-to-use feature-rich CSV library
  • Ease of Use
    • Fluent API to read/write CSV from/to almost any source/destination
    • Built-in support for common CLR types and interfaces like I(Utf8)SpanParsable
    • Full feature parity with sync and async APIs
    • Read or write UTF-8 bytes directly without a TextReader or TextWriter
    • Hot reload support for internal caches
  • High Performance
    • SIMD parsers tuned for each platform (AVX2, AVX512, ARM64)
    • Near-zero allocations irrespective of dataset size
    • Parallel APIs to read/write records in parallel
    • Low-level APIs to handle raw CSV field spans directly
  • Deep Customization
    • Attribute configuration for header names, constructors, field order, etc.
    • Support for custom converters and converter factories (like System.Text.Json)
    • Read or write multiple CSV documents from/to a single data stream
  • Source Generators
    • Library is fully annotated for NativeAOT and trimming
    • Source generated type maps for reflection-free reading and writing
    • Source generated enum converters with up to 10x better performance than Enum.TryParse/TryFormat

All of this without sacrificing ease of use.

Example

using FlameCsv;

const string data =
    """
    id,name,age
    1,Bob,42
    2,Alice,37
    3,"Bond, James",39
    """;

List<User> users = [];

// read users from utf16 string
foreach (var user in Csv.From(data).Read<User>())
{
    users.Add(user);
}

// write users to a stream as tab-separated fields
await Csv.To(stream, Encoding.UTF8).WriteAsync(
    users,
    new CsvOptions<char> { Delimiter = '\t' },
    cancellationToken);

Dependencies

FlameCsv has two dependencies:

  • CommunityToolkit.HighPerformance which provides utilities for writing high-performance code, and the string pool used for header values.
  • A development-time dependency to FastExpressionCompiler is used for extremely performant runtime code-generation in reflection-based code paths.