onlinecompiler.io

Node-RED node

Run code in any of 46 languages from a Node-RED flow, or judge it against test cases for a verdict and a score. Each run happens in a fresh sandbox with no network.

In Node-RED, open Manage palette, search for @onlinecompiler/node-red-onlinecompiler and install it. It is also in the Node-RED Flow Library and on npm. Or, in your Node-RED user directory (usually ~/.node-red):

Terminal
npm install @onlinecompiler/node-red-onlinecompiler

It needs Node-RED 3.0 or later on Node.js 18 or later. Get a free API key from the dashboard (key type API), then add an Account in the node and paste the key.

What it does

  • Run code: runs a program with optional standard input. msg.payload becomes its output, errors, status, exit code, time and memory.
  • Run code against test cases: runs the program once per test and returns a verdict for each test, an overall verdict and a score. Output can be compared as trim, exact, tokens, float, rows or tables.
  • List languages: returns every compiler id, such as python-3.14 or g++-15; they are also on the languages page.

Each setting (language, code, input, tests) can come from the message, a fixed value, flow or global context, or an environment variable. By default the code is msg.payload and the tests are msg.tests:

msg.tests
[
  { "input": "2 3", "expected_output": "5" },
  { "input": "10 -4", "expected_output": "6" }
]

A judged run sends on:

msg.payload
{
  "verdict": "accepted",
  "score": 100,
  "passed": 2,
  "total": 2,
  "tests": [ ... ]
}

Each run gets up to 30 seconds and 512 MB, with no network. Two example flows come with it, under Import, Examples: one runs a Python program, the other grades a submission against two tests.

Source and issues: github.com/onlinecompiler-io/node-red-onlinecompiler. The same checks are available over the run-tests API.

Questions

Why not use the Function node?
Node-RED's Function node runs JavaScript inside Node-RED itself. This node runs 46 languages, among them Python, C, C++, Java, Go, Rust and SQL, each run in a fresh sandbox with no network, so it suits code you didn't write: student submissions, code from a form, or code an AI model wrote.
Is it free?
Yes, with a free API key: the Free plan has 100,000 runs a month and needs no card. Each test in a judged run counts as one run.
Where is the API key kept?
In an Account config node, which Node-RED stores with its other credentials, not in the flow, so exporting or sharing a flow does not share the key.
What happens when a run fails?
A program that crashes or prints to standard error still comes back as a result, with its exit code and error text. When the API itself answers with an error (a bad key, too many runs a minute, an unknown language), the node sets msg.statusCode and reports the error, so a Catch node can handle it.