Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. Spark
  3. spark
  4. loadText

spark.loadText

function loadText(path: string): Promise<string>

Load a file from torchjs.org as text (UTF-8).

Convenience function for loading text files. The file is downloaded as an ArrayBuffer and decoded as UTF-8 text.

Use this for:

  • README and documentation files
  • Configuration files
  • Source code or scripts
  • Any text-based format
If the file is not valid UTF-8, the decode may produce replacement characters. For binary files, use load instead.

Parameters

pathstring
File path in format "username/project/filename" or "username/project/path/to/file"

Returns

Promise<string>– Promise that resolves to the file contents as a string (UTF-8 decoded)

Examples

// Load project documentation
const readme = await spark.loadText('kasumi/mnist/readme.txt');
console.log(readme);

// Load configuration
const config = await spark.loadText('kasumi/project/config.txt');

See Also

  • load - Load file as raw ArrayBuffer
  • loadJSON - Load and parse JSON
Previous
loadLocal
Next
MessageTarget