Go to example tasks

Run a JavaScript snippet on JSON input

Runs a Node.js snippet in an isolated sandbox: it reads a JSON object from standard input, computes sum, count, mean, max and min of `values`, and prints the result as JSON. The output is parsed into the `result` field. Edit `code` and `stdin` to run any transformation, with a 5-second timeout.

Try for free
AI Code Runner Sandbox
AI Code Runner Sandboxparsebird/code-runner-sandbox
Status
Language
Exit code
Signal
+6 fields
Text
Number
Boolean
List
Object

Input

Language:javascript
Code(required):const chunks=[]; for await (const c of process.stdin) chunks.push(c); const input=JSON.parse(Buffer.concat(chunks).toString()||'{}'); const v=input.values; const sum=v.reduce((a,b)=>a+b,0); console.log(JSON.stringify({sum, count:v.length, mean:sum/v.length, max:Math.max(...v), min:Math.min(...v)}));
Standard input:{"values": [3, 5, 8, 13, 21]}
Timeout (seconds):5

Output fields

Status
Language
Exit code
Signal
Duration (ms)
Timed out
Output truncated
Termination reason
Result parse error
Executed at

How it works

Sign up on Apify or log in

The AI Code Runner Sandbox Actor is ready to run with the inputs already set for "Run a JavaScript snippet on JSON input". Sign up or log in and you'll land in Apify Console with a copy of this exact task.

Start the "Run a JavaScript snippet on JSON input" task

The AI Code Runner Sandbox Actor will start running based on the input automatically. You can also change all the input fields, like language, code, and more, to match your specific use case.

Receive the "Run a JavaScript snippet on JSON input" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as status, language, exit code, and more.

Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also run the "Run a JavaScript snippet on JSON input" task via API.

Image

Integrate "Run a JavaScript snippet on JSON input" into your workflow

Connect "Run a JavaScript snippet on JSON input" with 100+ integrations, or run it via API or MCP.

Webhook

Webhook

n8n

n8n

Make

Make

Zapier

Zapier

Airbyte

Airbyte

Keboola

Keboola

IFTTT

IFTTT

Hubspot

Hubspot

GDrive

GDrive

Gmail

Gmail

Apify MCP

Apify MCP

GitHub

GitHub

Slack

Slack

LangChain

LangChain

LlamaIndex

LlamaIndex

Flowise

Flowise

Pinecone

Pinecone

OpenAI

OpenAI

Mastra

Mastra

Clay

Clay