fflat 2.1.3

dotnet tool install --global fflat --version 2.1.3
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local fflat --version 2.1.3
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=fflat&version=2.1.3
                    
nuke :add-package fflat --version 2.1.3
                    

fflat - F# native script compiler on bflat

<img alt="Nuget" src="https://img.shields.io/nuget/v/fflat">

Build 1MB native executables from .fsx scripts!

alternate text is missing from this package README image

Installation

# install the dependencies (on a debian-based system)
apt install -y libc++-dev
# install the global tool
dotnet tool install --global fflat

see ./Dockerfile for a self-contained example

Basic usage

fflat script.fsx             # about 1.4M, no debug/globalization/symbols
fflat script.fsx --small     # about 1MB, no reflection/exceptions, no printfn!

run fflat --help for a list of options

Advanced usage

arm64 executable

fflat script.fsx --arch arm64 # 1.4MB and runs on raspberry pi! 👍

using fflat to as an interface to the F# compiler

fflat ./mylibrary.fsx build-il --watch ## quickly recompiles mylibrary.dll on every change 
fflat ./helloworld.fsx --small --os windows ## ... etc

Shared library (experimental)

fflat script.fsx [--small] build-shared
all options
MAIN:

    <script>              .fsx script file path (first argument)

SUBCOMMANDS:

    build <options>       compile to native with bflat [default]
    build-il <options>    compile to IL (using fsc)
    build-shared <options>
                          compile to shared library

    Use 'fflat <subcommand> --help' for additional information.

OPTIONS:

    --verbose, -v         verbose output
    --version             version of application
    --ldflag <string>    <ldflag>
    --noreflection        disable reflection
    --arch <unknown|arm|arm64|x64|x86|wasm32|loongarch64>
                          <x64|arm64>
    --os <unknown|windows|linux|uefi>
                          <linux|windows|uefi>
    --optimize <none|prefersize|blended|preferspeed>
                          <preferspeed|prefersize>
    --small, -s           omits most useful features like reflection, exceptions, but produces smaller binaries
    --output, -o <outputFile>
                          output executable path
    --help                display this list of options.

Common questions, troubleshooting

Why?

there is almost a 1000x difference in startup time for dotnet fsi scripts using nuget!

alternate text is missing from this package README image

there is also FSharpPacker for .fsx scripts, which compiles .fsx scripts to native executables using the standard MSBuild pipeline (PublishAOT), but bflat can produce significantly smaller executables or even omit the .NET runtime/GC all together.

What's the smallest executable I can get?

there is a sample in ./samples/zerolib_16kb.fsx that produces a 16kb executable with the zerolib standard library. This excludes almost all of .NET and the F# core library. however it's not very useful and you'll have to write implementations for even basic features like for loops.

TypeInitialization_Type_NoTypeAvailable errors

don't use --small, --small will crash if your script uses any reflection features.

there's many untrimmable features in the F# core library like printfn, quotations and linq. substituting all printfn calls with stdout.WriteLine will produce significantly smaller binaries as well.


Have fun!

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
2.1.3 145 2/4/2026
2.1.2 117 2/4/2026
2.1.1 131 2/3/2026 2.1.1 is deprecated because it has critical bugs.
2.1.0 126 2/2/2026 2.1.0 is deprecated because it has critical bugs.
2.0.7 1,144 12/13/2024
2.0.5 655 12/13/2024
1.0.53 3,386 7/6/2024
1.0.52 3,151 7/6/2024
1.0.49 7,187 6/22/2024
1.0.48 8,499 1/30/2024
1.0.47 3,351 1/30/2024
1.0.46 11,538 11/18/2023
1.0.44 4,275 10/18/2023
1.0.43 2,620 10/9/2023
1.0.36 2,408 10/9/2023
1.0.34 1,782 10/8/2023
1.0.33 2,764 10/8/2023