readfile Synchronous

  • readfileasync

Read a workspace file as a Luau string. Strings can hold arbitrary bytes, so the same call can load settings text or an image you plan to pass to another API.

Syntax
Luau
readfile(path: string) -> string

Parameters

Function parameters
ParameterTypeDescription
pathstringWorkspace-relative file path.

Returns

string

The complete file contents as a string.

Usage notes

A missing file or invalid workspace path raises. Check isfile first when the file is optional.

Differences from Volt

Volt documents access through explicitly created workspace symlinks. Kawaii rejects symlinks in workspace paths; all workspace operations remain subject to its path containment checks.

Example

Example
Luau
local path = "settings.json"
if isfile(path) then
    print("Saved settings:", readfile(path))
else
    print("No saved settings yet")
end
Kawaii documentation