11 releases

0.3.8 Feb 3, 2026
0.3.7 Feb 3, 2026
0.3.6 Jan 31, 2026
0.2.0 Jan 11, 2026
0.1.2 Jan 28, 2026

#1730 in Parser implementations


Used in niblits

GPL-3.0-or-later

21MB
471K SLoC

Rust 242K SLoC // 0.0% comments Objective-C 35K SLoC // 0.0% comments Bitbake 27K SLoC // 0.0% comments JavaScript 23K SLoC // 0.2% comments C 23K SLoC // 0.2% comments Coq 12K SLoC // 0.1% comments C++ 8K SLoC // 0.2% comments OCaml 7.5K SLoC // 0.0% comments Perl 7.5K SLoC // 0.0% comments Modelica 5.5K SLoC // 0.0% comments Gml 4.5K SLoC // 0.3% comments F# 4.5K SLoC // 0.0% comments Wolfram 4.5K SLoC // 0.0% comments Odin 4K SLoC // 0.1% comments PHP 4K SLoC // 0.4% comments TypeScript 3.5K SLoC // 0.1% comments VB6/VBA 3.5K SLoC // 0.0% comments FORTRAN Legacy 3K SLoC // 0.0% comments Java 3K SLoC // 0.2% comments Assembly 3K SLoC // 0.0% comments Ruby 2.5K SLoC // 0.2% comments Lex 2K SLoC // 0.1% comments TSX 2K SLoC // 0.0% comments Objective-C++ 1.5K SLoC // 0.2% comments Go 1.5K SLoC // 0.2% comments Chapel 1.5K SLoC // 0.3% comments Forth 1.5K SLoC // 0.1% comments SWIG 1K SLoC // 0.1% comments Python 1K SLoC // 0.3% comments SQL 1K SLoC // 0.1% comments ShaderLab 1K SLoC // 0.1% comments ATS 1K SLoC // 0.4% comments Alex 1K SLoC Vim Script 1K SLoC // 0.1% comments CoffeeScript 1K SLoC // 0.2% comments D 891 SLoC // 0.2% comments Ren'Py 844 SLoC // 0.1% comments Visual Basic 797 SLoC // 0.1% comments GLSL 779 SLoC // 0.2% comments MoonScript 714 SLoC // 0.0% comments RPM Specfile 676 SLoC // 0.2% comments Puppet 649 SLoC // 0.1% comments Crystal 630 SLoC // 0.0% comments WebAssembly 596 SLoC // 0.0% comments LOLCODE 590 SLoC // 0.2% comments Scala 584 SLoC // 0.1% comments OpenCL 555 SLoC Unreal Script 534 SLoC // 0.1% comments HolyC 506 SLoC // 0.0% comments Prolog 481 SLoC // 0.2% comments Pony 475 SLoC // 0.1% comments Pan 453 SLoC // 0.2% comments GNU Style Assembly 445 SLoC Nim 437 SLoC // 0.1% comments HLSL 428 SLoC // 0.0% comments GDScript 424 SLoC // 0.7% comments ActionScript 404 SLoC // 0.0% comments Nextflow 381 SLoC // 0.3% comments Phix 372 SLoC // 0.1% comments Forge Config 365 SLoC // 0.1% comments Common Lisp 358 SLoC // 0.2% comments Swift 351 SLoC // 0.0% comments Max 337 SLoC F* 332 SLoC // 0.1% comments Emacs Lisp 327 SLoC // 0.2% comments R 324 SLoC // 0.2% comments Dhall 295 SLoC PureScript 275 SLoC // 0.0% comments Alloy 226 SLoC // 0.3% comments Snakemake 225 SLoC // 0.0% comments SRecode Template 209 SLoC // 0.0% comments SystemVerilog 199 SLoC Raku 195 SLoC // 0.1% comments Q 190 SLoC // 0.2% comments BrightScript 189 SLoC // 0.3% comments C# 183 SLoC // 0.1% comments Erlang 179 SLoC // 0.0% comments HCL 177 SLoC // 0.1% comments Haskell 176 SLoC // 0.2% comments Ruby HTML 166 SLoC LiveScript 165 SLoC // 0.1% comments M4 165 SLoC // 0.3% comments CodeQL 163 SLoC // 0.2% comments ColdFusion CFScript 153 SLoC // 0.3% comments Bazel 152 SLoC // 0.2% comments PlantUML 146 SLoC // 0.0% comments Elm 143 SLoC // 0.3% comments Razor 143 SLoC // 0.0% comments PowerShell 140 SLoC // 0.4% comments Ur/Web 130 SLoC // 0.1% comments ABAP 128 SLoC // 0.4% comments Glimmer TS 128 SLoC Liquid 121 SLoC // 0.2% comments Zig 106 SLoC // 0.0% comments Visual Studio Project 104 SLoC ABNF 102 SLoC // 0.2% comments VBScript 101 SLoC // 0.0% comments Redscript 96 SLoC AWK 94 SLoC // 0.2% comments ZenCode 91 SLoC // 0.2% comments Xtend 90 SLoC // 0.3% comments GraphQL 80 SLoC // 0.1% comments Lean 78 SLoC // 0.4% comments Metal Shading Language 77 SLoC Edn 76 SLoC Open Policy Agent 73 SLoC // 0.3% comments Stan 68 SLoC Ballerina 64 SLoC // 0.2% comments Standard ML (SML) 53 SLoC Svelte 53 SLoC Cabal 52 SLoC // 0.0% comments FreeMarker 50 SLoC // 0.1% comments BASH 49 SLoC // 0.1% comments Arduino C++ 47 SLoC // 0.1% comments .NET Resource 45 SLoC // 0.6% comments SQF 44 SLoC // 0.3% comments Kotlin 40 SLoC Jsonnet 40 SLoC // 0.3% comments ColdFusion 40 SLoC // 0.2% comments Racket 38 SLoC // 0.1% comments Oz 36 SLoC // 0.3% comments Pacman's makepkg 35 SLoC Isabelle 32 SLoC // 0.1% comments Idris 31 SLoC Jupyter Notebooks 31 SLoC // 0.3% comments Groovy 29 SLoC // 0.1% comments Agda 27 SLoC // 0.1% comments CUDA 27 SLoC // 0.3% comments Nushell 25 SLoC AsciiDoc 25 SLoC Shell 25 SLoC // 0.2% comments Stylus 24 SLoC Julia 24 SLoC // 0.2% comments XSL 22 SLoC COBOL 21 SLoC JSX 20 SLoC jq 19 SLoC Processing 19 SLoC // 0.3% comments PostCSS 17 SLoC // 0.1% comments Handlebars 15 SLoC Dart 15 SLoC Hy 15 SLoC // 0.1% comments Ceylon 13 SLoC ClojureC 13 SLoC Vue 12 SLoC GDB Script 12 SLoC // 0.6% comments ClojureScript 11 SLoC OpenQASM 11 SLoC VHDL 10 SLoC Clojure 10 SLoC // 0.3% comments OpenSCAD 10 SLoC // 0.3% comments Pug 9 SLoC Verilog 8 SLoC APL 8 SLoC // 0.2% comments Stata 7 SLoC // 0.5% comments Logtalk 3 SLoC // 0.5% comments Thrift 3 SLoC Haml 3 SLoC Zsh 1 SLoC

Contains (obscure autoconf code, 5KB) samples/M4Sugar/filenames/configure.ac

Palate

File type detection combining the best of tft and hyperpolyglot.

Acknowledgments

This project is a reassembly of code from several excellent projects:

  • tft - Tree-sitter File Type, providing fast file type detection using tree-sitter grammars
  • Neovim - The original source of filetype detection heuristics and patterns
  • hyperpolyglot - Language detection library with comprehensive language patterns

This crate essentially combines and curates the detection logic from these sources into a unified, ergonomic API.

License

GPL-3.0-or-later

This project is derived from tft (GPL-3.0-or-later), which itself incorporates code from Neovim (Apache-2.0/Vim license). As a derivative of GPL-3.0 work, this project is licensed under GPL-3.0-or-later.

Features

  • Comprehensive file type detection
  • Fast PHF-based lookups
  • Content-based detection with heuristics
  • Naive Bayes classifier fallback (with classifier feature)

Usage

use palate::{detect, FileType};

// Detect file type with fallback to Text
let ft = detect("main.rs", "");
assert_eq!(FileType::Rust, ft);

// Try detection without fallback
let ft = palate::try_detect("unknown.xyz", "");
assert_eq!(None, ft);

Detection Pipeline

  1. Path suffix matching
  2. Filename matching
  3. Pattern matching (with priorities)
  4. File extension matching (PHF map)
  5. Negative priority patterns
  6. Content-based detection (dynamic resolvers)

Features

  • detect (default): Enable file type detection
  • classifier: Enable naive Bayes classifier
  • serde: Enable serde serialization for FileType

Dependencies

~4.5–10MB
~175K SLoC