MagikaSharp 9.0.2

dotnet add package MagikaSharp --version 9.0.2
                    
NuGet\Install-Package MagikaSharp -Version 9.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MagikaSharp" Version="9.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MagikaSharp" Version="9.0.2" />
                    
Directory.Packages.props
<PackageReference Include="MagikaSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MagikaSharp --version 9.0.2
                    
#r "nuget: MagikaSharp, 9.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MagikaSharp@9.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MagikaSharp&version=9.0.2
                    
Install as a Cake Addin
#tool nuget:?package=MagikaSharp&version=9.0.2
                    
Install as a Cake Tool

πŸ“¦ MagikaSharp

MagikaSharp is an unofficial .NET wrapper for Google’s magika file type detection system. It provides a clean and safe C# API on top of a high-performance Rust FFI integration using ONNX Runtime.

MagikaSharp brings Magika’s machine-learning-powered file type identification to the .NET ecosystem, supporting:

  • βœ” Windows
  • βœ” Linux
  • βœ” macOS (Apple Silicon)

✨ Features

  • πŸ” Fast and accurate file type detection
  • πŸ“„ Detailed metadata (label, mime, description, extensions, category, text/binary flag)
  • ⚑ High-performance Rust backend with native ONNX Runtime
  • 🧡 Safe managed API with automatic memory handling
  • πŸ“¦ Cross-platform native runtime packing (NuGet-friendly)

πŸ“₯ Installation

Install from NuGet:

dotnet add package MagikaSharp

πŸš€ Quick Example

using MagikaSharp;

using var magika = new MagikaSession();

var info = magika.IdentifyFile("example.pdf");

Console.WriteLine($"Label: {info.Label}");
Console.WriteLine($"MIME: {info.MimeType}");
Console.WriteLine($"Group: {info.Group}");
Console.WriteLine($"Description: {info.Description}");
Console.WriteLine("Extensions: " + string.Join(", ", info.Extensions));
Console.WriteLine($"IsText: {info.IsText}");

πŸ“š API Highlights

Identify a file

var info = magika.IdentifyFile("file.bin");

Identify in-memory bytes

var info = magika.IdentifyBytes(data);

Returned info object

public sealed class MagikaTypeInfo
{
    public string Label { get; }
    public string MimeType { get; }
    public string Group { get; }
    public string Description { get; }
    public string[] Extensions { get; }
    public bool IsText { get; }
}

βš™οΈ How It Works

MagikaSharp ships with:

  • Native Rust library (libmagika_ffi)
  • Bundled ONNX Runtime dependencies
  • A thin and safe C# P/Invoke layer
  • A high-level managed API class (MagikaSession)

At runtime, MagikaSharp dynamically loads the correct native library based on the current platform.


πŸ“ Notes

MagikaSharp is not affiliated with Google. Magika is a Google project released under the Apache 2.0 license.

This library aims to:

  • provide reliable .NET bindings
  • support Linux/Windows/macOS
  • make Magika easy to consume in .NET apps and services

This project includes components from:

  • Google Magika (Apache License 2.0)
  • ONNX Runtime (MIT License)

MagikaSharp is an independent project and is not affiliated with Google.


🀝 Contributing

PRs, issue reports, and suggestions are welcome!


πŸ“„ License

  • MIT
  • Magika itself is Apache 2.0.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.2 934 1/22/2026
9.0.1 235 11/24/2025
9.0.0 194 11/23/2025