EditSafely

Apply a Function on a List

Run a JavaScript function on every list item.

Runs on your device, nothing uploaded

Function (item, index) => resultA JavaScript function that gets each item (and its index) and returns the new item.
Try:

0 chars · 0 lines

Output

Run a JavaScript function on every list item.

Type or paste above to see the result here.

Example: Uppercase every item

What you paste never leaves this tab

Apply a Function on a List is JavaScript that your browser has already downloaded, and it does the whole job on your own machine. On a normal site, the text you paste is sent to a server that can log it, cache it or keep it. Here it is read and transformed inside this tab and nowhere else.

  • No upload
  • No length limit
  • Works offline once loaded
  • Nothing stored or logged

How to use Apply a Function on a List

  1. 1. Paste your list. Enter your items into the input pane, one per line. Any list you want transformed by custom logic rather than a fixed built-in operation works here.
  2. 2. Write a function. Type a JavaScript function in the field above the list, or tap a Try chip such as Domain or Length. It runs once per item, receiving the item's text and its position, and returns the new value.
  3. 3. Copy the transformed list. The result has one line per item. If the function returns undefined, for example because of a typo like item.toUpp, a warning says so instead of filling the list with the word undefined.

When to use Apply a Function on a List

Apply a Function on a List runs a small JavaScript function against every item in a pasted list, letting you write custom logic instead of relying on a fixed built-in transformation. Use it whenever a specific list tool doesn't already exist for your case.

  • Uppercasing every item with a one-line function. You need every item converted to uppercase, and writing 'item.toUpperCase()' as the function body applies that transformation across the whole list in one pass.
  • Adding the item's position into the text. A list needs each item annotated with its own index, such as 'apple (0)', which a function using both the item and index parameters can produce directly.
  • Applying a custom calculation to a list of numbers. A list of numeric strings needs each value doubled or converted with a formula, and writing that calculation as a function applies it to every line at once.
  • Combining several transformations in one pass. A list needs trimming, case conversion and a prefix added all at once, and writing one function that does all three avoids running three separate tools in sequence.

Examples

Uppercase every item

Input

cats
dogs

Output

CATS
DOGS

Number the items

Input

cats
dogs

Output

1. cats
2. dogs

Email addresses to domains

Input

ana@example.com
bo@site.org

Output

example.com
site.org

Trim and capitalise

Input

 apple
banana 

Output

Apple
Banana

Length of each item

Input

cat
horse

Output

3
5

About the Apply a Function on a List tool

Apply a Function on a List is a free online tool that works entirely inside your web browser. Run a JavaScript function on every list item. Because the processing happens on your own device, nothing you enter is uploaded, logged or stored anywhere.

This page is one of 114 List utilities on EditSafely. Each one does a single job well, and all of them follow the same rule: your input stays on your machine.

You can shape the output with the Function (item, index) => result setting, and the result refreshes the moment you change it. 5 worked examples further down the page show exactly what the tool produces for real inputs.

Because nothing leaves your device, the tool is suitable for sensitive content such as internal documents, credentials or customer data. It also responds instantly, since every step is handled on your own machine rather than by a remote API.

Frequently asked questions

Is Apply a Function on a List free to use?

Yes, it is completely free. All 2,943 tools on EditSafely work without an account, a subscription or usage limits.

Is it safe to paste sensitive or confidential data?

Everything happens locally. Your browser downloads the tool's code once, then does all the processing itself; nothing you enter is transmitted, stored or logged. You can even go offline after the page loads and it will still work.

How much text can I process at once?

There is no fixed limit; your device's memory is the ceiling. Up to 10 MB the result updates as you type, after a short pause that grows with the size. Above 10 MB a Run button appears so typing stays smooth, and files open up to 50 MB. A very long result shows its first 2,000 lines on screen, while Copy and Download always include all of it.

Do I need to sign up or install anything?

No. The tool works in any modern browser on desktop, tablet or phone. There is no account to create, no extension to add and no software to install.

How do I use the result?

The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.

Related tools

All List Tools →