Fuzzy Search – Fuse.js-inspired fuzzy matching for Roblox

[Module Release] FuzzySearch – Fuse.js-inspired fuzzy matching for Roblox

Hey everyone!
I made a lightweight fuzzy search module for Roblox, inspired by the popular JavaScript library Fuse.js.

This module lets you search through arrays of strings or objects even if the search term isn’t exact — great for player search bars, autocomplete, inventory filters, and more.


Features

  • :magnifying_glass_tilted_left: Fuzzy matching using Levenshtein distance (typo-tolerant search)
  • :package: Works with strings or tables (object search with key selection)
  • :gear: Adjustable threshold (how strict/loose matches are)
  • :input_latin_uppercase: Optional case-sensitive matching
  • :bar_chart: Results sorted by relevance

Example with strings

local FuzzySearch = require(path.to.FuzzySearch)

local fruits = {"apple", "orange", "banana", "pineapple"}
local searcher = FuzzySearch.new(fruits, {threshold = 0.4})

local results = searcher:search("aple")
for _, result in ipairs(results) do
    print(result.item, result.score)
end

Output:

apple      0.2
pineapple  0.36

Example with objects

local people = {
    {name = "John Doe", job = "Developer"},
    {name = "Jane Smith", job = "Designer"},
    {name = "Jake Johnson", job = "Doctor"}
}

local searcher2 = FuzzySearch.new(people, {
    threshold = 0.3,
    keys = {"name", "job"}
})

local results2 = searcher2:search("Desiner")
for _, result in ipairs(results2) do
    print(result.item.name, result.item.job, result.score)
end

Output:

Jane Smith  Designer  0.18

API

FuzzySearch.new(list, options)

  • list{string} or {table}

  • options table:

    • threshold (number) → 0 = exact match, 1 = match everything (default: 0.4)
    • keys (array of strings) → Keys to search in objects
    • caseSensitive (boolean) → true/false (default: false)

search(pattern)

  • Returns { {item = any, score = number}, ... } sorted by best score first.

Update – Flexible Key Paths

:one: Nested Key Paths

You can now use dot notation in the keys option to search inside nested tables:

keys = {"name", "job.name"}

Example:

local people = {
    {name = "John Doe", job = {name = "Developer", Salary = 2000}},
    {name = "Jane Smith", job = {name = "Doctor", Salary = 3000}},
    {name = "Jake Johnson", job = {name = "Designer", Salary = 1500}}
}

local searcher = FuzzySearch.new(people, {
    threshold = 0.3,
    keys = {"name", "job.name"}
})

local results = searcher:search("Desiner")
for _, result in ipairs(results) do
    print(result.item.name, result.item.job.name, result.score)
end

:two: Wide Search with .*

You can now search all child string properties of a given path using .* at the end:

keys = {"name", "job.*"}

This will search "name" directly, and all string properties in job, without listing them individually.


:three: Root-Level Wide Search

You can even use ".*" as a root-level wide search to search all string properties in the object, no matter how deeply nested:

keys = {".*"} -- searches everything in the object recursively

:floppy_disk: Get the module [Free]:
FuzzySearch - Developer Marketplace

:hot_beverage: Support the Project:
This module is and will remain 100% free.
If it saved you time or helped your game, consider buying me a coffee — it helps me keep making tools like this for the community.
:right_arrow: FuzzySearch Support - Roblox


Thanks for reading! :slight_smile:

Simonp Studios - Roblox

19 Likes

Appreciate it! Can I use this for commercial scopes?

Can we use objects for keywords?

Yeah you can use it for your own projects, tough I would appretiate to be credited. What did you mean with objects for keywords? Using an object as a query? Or adding property keys from objects which are inside the main object?

What I meant is to put an array of alternative phrases inside an object as keywords. So basically, each object would have a property holding multiple possible keywords or phrases to match against, instead of just one string.

Could you show me an example of the object structure?

Something like this {name = “orange”, keywords = “rounded-shaped fruit”, “orange fruit”},

Basically a key with an array

Alr I’ll add a new feature to support this

Hi, I updated the module with a flexible key path functionality. So now you can make a fuzzy search in your object by adding the option

keys = {"keywords.*"}

or

keys = {".*"}

if the name property should also be included.
Check out the post for more information.

1 Like

Awesome. It’s a very nice module! You could open source this on github

2 Likes

Yeah already thought about that I’ll probably do it.

Done! FuzzySearch-Roblox - Github

1 Like

We could contribute, if you want

1 Like

Sure, every help is welcome. How would you like to contribute?

1 Like

Idk lol. I’m just a graphic designer

Hahhah dont worry I will tell you if I need a graphic designer

1 Like

any way you can make this search for literal keys in a table? it doesn’t seem to do that currently, unless i’m missing something. EDIT: nvm, made it do that myself

1 Like

Does this garbage collect? for data of an inventory that is changing of course, im wondering if when a new search is made that the old table is gc?

1 Like

Yes, it garbage collects perfectly. The module doesn’t store any history or permanent references to old searches. Every time you call :search(), it generates a local results table that is cleared from memory by Luau’s Garbage Collector as soon as you’re done using it. It’s safe to use with dynamic inventories.