https://github.com/nandubit/loadstring
A lightweight Node.js utility to execute JavaScript from strings or URLs — inspired by Lua's loadstring().
https://github.com/nandubit/loadstring
fetch fetch-api javascript js loadstring lua url
Last synced: 7 months ago
JSON representation
A lightweight Node.js utility to execute JavaScript from strings or URLs — inspired by Lua's loadstring().
- Host: GitHub
- URL: https://github.com/nandubit/loadstring
- Owner: NanduBit
- License: mit
- Created: 2025-07-13T15:52:19.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-07-13T16:37:16.000Z (9 months ago)
- Last Synced: 2025-07-13T17:41:48.705Z (9 months ago)
- Topics: fetch, fetch-api, javascript, js, loadstring, lua, url
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/loadstring
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

💉 loadstring
A lightweight Node.js utility to execute JavaScript from strings or remote URLs — inspired by Lua's `loadstring()`.
---
### ⚙️ Requires Node.js **v20 or higher**
---
## 🚀 Features
- ✅ Run JavaScript from a string
- 🌐 Load & execute code from a remote URL
- 🧠 Smart `load()` function auto-detects string vs. URL
- ✨ Zero Dependencies
- ⚡ Simple, async-friendly API
---
## 📥 Installation
```bash
npm install loadstring
```
---
## ✨ Usage
### 1. Run a JavaScript string
```js
const { loadString } = require('loadstring');
// import { loadString } from 'loadstring';
loadString(`console.log("Hello from string!");`);
loadString(`
console.log("Log 1");
console.log("Log 2");
`);
```
---
### 2. Run JavaScript from a URL
```js
const { loadStringFromURL } = require('loadstring');
// import { loadStringFromURL } from 'loadstring';
loadStringFromURL('https://example.com/script.js');
// We recommend using pastebin links to inject yiur code via link (make sure u have pastebin link to the raw code)
```
If `https://example.com/script.js` contains:
```js
console.log("🔥 Remote code executed!");
```
You’ll see:
```
🔥 Remote code executed!
```
---
### 3. Smart `load()` — automatically runs string or URL
```js
const { load } = require('loadstring');
// import { load } from 'loadstring';
// Runs a code string
load('console.log("From string!")');
// Loads and runs from a remote URL
load('https://example.com/hello.js');
```
---
## 📘 API
### `loadString(code: string): void`
Executes a string of JavaScript code.
---
### `loadStringFromURL(url: string): Promise`
Fetches JavaScript code from a remote URL and executes it.
---
### `load(input: string): Promise`
Smart loader — detects if the input is a URL and runs accordingly.
---
## ⚠️ Security Warning
This module uses `new Function()` under the hood.
> ❗️ Never run untrusted or user-generated input — this allows full code execution.
---
## 🔒 License
MIT