Greetings and welcome to this small tutorial!
If you’ve encountered difficulties extracting a Roblox Lua-table from a string, then you’re in the right place as I have developed a module specifically designed to getting that actual Roblox Lua-table from a string using a better loadstring alternative method, so that other people don’t have to go through the pain.
This converter is designed to get the actual Lua-table from a string-table, raw link or even through a JSON-Encoded-table (which you can also archive with HTTPService:JSONDecode())
The module is uploaded on my current main account’s profile and has been made open-source (published incase of updates), meaning that you can simply require it by using the following require method (below):
Requirements:
-
The module (Obviously as a source):
require(113691930527921).StringTableToTable(stringTable, boolTryToFixLink, boolWarnErrorInfo)
-
HTTP-Service must be enabled if you work with links:
(To be able to access third-party-requested links and use them inside the module)
Current and possible arguments for the module:
-
stringTable
→ Can be: (string-table / raw link / JSON-Encoded-table). -
boolTryToFixLink (true by default)
→ A boolean for fixing raw links properly through the tryFixingLink function -
boolWarnErrorInfo (true by default)
→ A boolean for the warning & error output
How to use it:
First you have to require the module and use the module.StringTableToTable function, then you put in the “stringTableHere” argument either one of these following things:
-
A string-table
-
A raw link containing the string-table
-
A JSON Encoded string-table
Examples on how you could use it:
(The table in the pastebin is structured like a normal Lua-table format):
{
["SpecialTree"] = {
["Apple"] = 5,
["Banana"] = 3,
["Nuts"] = 4
}
}
Let’s try getting it from a raw link (pastebin) with the module!
local result = require(113691930527921).StringTableToTable("https://pastebin.com/gKa8bR0x")
print(result.SpecialTree.Apple)
Output:
5 ← (Apple from SpecialTree)
Great!
Let’s try that now from another raw link (pastebin) that is this time structured into the Encoded JSON format:
(The table in the pastebin is this time structured in an Encoded JSON table format):
{"SpecialTree":{"Apple":5,"Banana":3,"Nuts":4}}
Let’s try getting it from the raw link (pastebin) with the module!
local result = require(113691930527921).StringTableToTable("https://pastebin.com/xd4F0feH")
print(result.SpecialTree.Banana)
Output:
3 ← (Banana from SpecialTree)
Keep in mind:
-
Links will be automatically converted into /raw links incase they aren’t by my module if supported in the applicableDomains list ONLY if boolTryToFixLink (the second argument) is considered true (which it is by default).
-
Using HTTPService:GetAsync() is willing to return the information as a string, which when you have a table inside that information we then consider as a string-table. That’s why I made this module so we don’t have to deal with that problem and we can easily get the actual Lua-table back with the help of my module!
(So it will be “readable” for Lua)
Now let’s try something different instead of using pastebin…
local StringTable = [[{
["Name"] = "John",
["Job"] = "Police Officer",
["Level"] = 32
}]]
local result = require(113691930527921).StringTableToTable(StringTable)
local Name = result.Name
local Job = result.Job
local Level = result.Level
print("Name: "..Name.." / ".."Job: "..Job.." / ".."Level: "..Level)
Output:
Name: John / Job: Police Officer / Level: 32
And that’s it!
The module will then (if used correctly) return the string table to an actual Roblox Lua-table that you can use further in your scripts thanks to the loadstring module. If the string table contains an invalid format then it warns the error out (depending if boolWarnErrorInfo is true), and usually returns the table to nil to prevent script errors.
Why did I make this module?
-
Because I’ve seen a lot of people that have been using Roblox’s .LoadStringEnabled method which is a working one BUT extremly unsafe method at the same time, as it simply makes exploiters vulnerable to use loadstring() to take control of the game if used uncorrectly.
-
I also made this module because I know that a lot of people love to use the normal Lua-table format, as it may be simpler to-use, are used to work with them, and may be better readable than a JSON table.
-
And most importantly, to keep everything orginized and have easy access to everything at once, basically (All-In-One).
For what would this be useful?
- This would be extremely useful for making list-themed scripts like a ban list for example via third-party raw link domain sites especially for: pastebin.com, pastes.io or even snippet.host etc…
Fun fact & Backstory
The actual idea behind the module, when I first tried making it, was to use hard-coded string pattern matching logic to convert a string table into a Lua table. However, I quickly realized that this approach wouldn’t work without using a separate loadstring module, as it’s simply impossible without one.
Here is what my actual idea of the code looked like (scrapped code):
local pastebinLink = "https://pastebin.com/raw/7xyN5Z9S"
local scriptString = game:GetService("HttpService"):GetAsync(pastebinLink)
local innerContent = scriptString:match("{(.+)}")
local loadedTable = {}
for outerKey, innerContent in innerContent:gmatch('%s*%["(.-)"%]%s*=%s*{(.+)}%s*,?%s*') do
loadedTable[outerKey] = {}
for key, value in innerContent:gmatch('%s*%["(.-)"%]%s*=%s*(%d+),?%s*') do
loadedTable[outerKey][key] = tonumber(value)
end
end
for outerKey, innerTable in pairs(loadedTable) do
print("Category:", outerKey)
for key, value in pairs(innerTable) do
print(key, value)
end
print("Here is the table: ")
print(innerTable.Banana)
end
Thank you for making it this far of this tutorial, I hope you enjoyed this short tutorial on how to use Bey’s String Table to Table Converter - Roblox
(Feedbacks are very welcome)
-CHANGELOG
Click here to view all updates & changes
Latest update - 04/08/2025:
-
When you paste a full Gist URL (even with commit hashes, filenames, or query parameters), the module will now use the GitHub API to dynamically fetch the latest version of the file
-
If the API is unavailable or fails for any reason, it will gracefully fall back to the previous method using /raw and a cache-busting ?no-cache query
Update - 04/07/2025:
-
You can now paste the full Gist link (even with filenames, hashes, or query params), and the module will automatically trim everything after /raw easily for you
-
The
tryFixingLink
function is now accessible directly from the module, making it easier to run tests or process links manually if needed!
Update - 04/06/2025:
- Added support for the popular raw link domain gist.github.com. It now handles cache-busting with
/?nocache=tick()
after/raw
to ensure the most up-to-date data is always fetched.
Update - 04/05/2025:
-
Finally figured out a way on how to distribute the module to the marketplace as Roblox Support simply wouldn’t assist me a single bit due to their lack of care for their developers.
-
Improved the loadstring module so it can convert string tables into Lua tables more efficiently.
-
Made some changes to the Devforum post with the formatting & writing
Update - 16/10/2024:
-
As of the 10/16/2024-10/17/2024 I have inserted 2 giant maps inside the Module as Roblox keeps on denying Appeals on the Asset even though it’s clearly not “Misusing Roblox’s Systems”, which didn’t work out too, but now as of the 10/22/2024 it seems that Roblox may have improved the way they moderate models and the Module is now finally public!
-
Reuploaded the module due to my false account terminations incident and almost rescripted the entire logic, as the module used to be sort of broken & outdated due to the Luau Module that I had overwritten last time, because of how good it currently is and also made a bunch of improvements
-
Added support for a popular raw link domain snippet.host
-
Improved Devforum post (formatting, writing, new title, etc…)
Update (more of a bug fix) - 01/03/2024:
-
Added a new function called
tryFixingLink
that allows for easy modifications of supported domains and customization with theapplicableDomains
list -
The module now works with every link, not only from
applicableDomains
-
Now supports the raw link domain pastes.io, where the new
tryFixingLink
function will convert links into proper /raw links and apply its custom unique modifications
Have fun using my module and stay safe!
Goodbye!