Skip to main content

Apache Fory™

A blazingly-fast multi-language serialization framework for idiomatic domain objects, schema IDL, and cross-language data exchange

Cross-language encoding

Exchange compact binary payloads across runtimes with schema evolution, shared and circular references, and polymorphic runtime types.

Domain objects first

Serialize native domain objects directly, including Java classes, Python dataclasses, Go structs, Rust and C++ structs, and generated or annotated types.

Reference-aware Schema IDL

Define schemas once, including shared and circular references, then generate native domain objects without wrapper types.

Row-format random access

Read fields, arrays, and nested values without rebuilding whole objects, with zero-copy access, partial reads, and Arrow integration.

Optimized runtimes

Java JIT serializers and generated or static serializers in other runtimes keep hot paths fast and serialized data compact.

Broad platform support

Use Fory from Java, Python, C++, Go, Rust, JavaScript/TypeScript, C#, Swift, Dart, Scala, Kotlin, GraalVM, Flutter, Node.js, and browsers.

Quick Start

Choose a runtime to open the matching quick start guide.

import java.util.List;
import java.util.Arrays;
import org.apache.fory.*;

public class Example {
  // Note that Fory instances should be reused between
  // multiple serializations of different objects.
  static ThreadSafeFory fory = Fory.builder().withLanguage(Language.JAVA)
    // Allow to deserialize objects unknown types,
    // more flexible but less secure.
    // .requireClassRegistration(false)
    .buildThreadSafeFory();

  static {
    // Registering types can reduce class name serialization
    // overhead but not mandatory.
    // If secure mode enabled
    //all custom types must be registered.
    fory.register(SomeClass.class);
  }

  public static void main(String[] args) {
    SomeClass object = new SomeClass();
    byte[] bytes = fory.serialize(object);
    System.out.println(fory.deserialize(bytes));
  }
}