A lightweight Node.js utility to execute JavaScript from strings or remote URLs — inspired by Lua's loadstring().
- ✅ 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
npm install loadstringconst{ loadString }=require('loadstring');// import { loadString } from 'loadstring';loadString(`console.log("Hello from string!");`);loadString(` console.log("Log 1"); console.log("Log 2");`);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:
console.log("🔥 Remote code executed!");You’ll see:
🔥 Remote code executed!
const{ load }=require('loadstring');// import { load } from 'loadstring';// Runs a code stringload('console.log("From string!")');// Loads and runs from a remote URLload('https://example.com/hello.js');Executes a string of JavaScript code.
Fetches JavaScript code from a remote URL and executes it.
Smart loader — detects if the input is a URL and runs accordingly.
This module uses new Function() under the hood.
❗️ Never run untrusted or user-generated input — this allows full code execution.
MIT
