How it works
- Paste the code you want to understand: a function, a SQL query, a shell command, a regex or a whole short file.
- Pick your experience level and, if you like, ask the one thing that's confusing you. Click Explain this code.
- Read the summary first, then follow the steps against the code. The Things to know section lists what usually trips people up.
Examples
Sample results for the inputs shown, so you can see the format and quality before you try it.
Example 1: inputCode to explain: SELECT customer_id,
order_date,
amount,
SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date) AS running_total,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date DESC) AS recency_rank
FROM orders
WHERE order_date >= '2026-01-01';
Your experience: Some experience
Example 1: outputWhat it does:
For every order placed since January 1, 2026, this query shows the customer, date and amount, plus two extra columns: how much that customer has spent so far (a running total) and how recent the order is compared with that customer's other orders.
Step by step:
1. FROM orders WHERE order_date >= '2026-01-01' takes only this year's orders.
2. SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date) adds up amounts one customer at a time, in date order. Each row shows the total up to and including that order, so a customer's third order shows the sum of their first three.
3. ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date DESC) numbers each customer's orders from newest (1) to oldest. Filtering on recency_rank = 1 in an outer query would give each customer's latest order.
4. Unlike GROUP BY, these window functions keep every row; they add columns instead of collapsing rows.
Things to know:
- If a customer has two orders on the same date, the running total counts both on each of those rows, because the default window includes ties. Add a tie-breaker such as order_id to ORDER BY if you want one row at a time.
- Orders before 2026 are excluded before the running total is calculated, so it's a total for this year, not all time.
- You can't use recency_rank in this query's WHERE clause; wrap the query and filter outside it.
Example 2: inputCode to explain: find . -name '*.log' -mtime +7 -print0 | xargs -0 gzip
Your experience: New to coding
Example 2: outputWhat it does:
Finds every file ending in .log under the current folder that was last modified more than 7 days ago, and compresses each one with gzip.
Step by step:
1. find . searches the current folder and every folder inside it.
2. -name '*.log' keeps files whose names end in .log. The quotes stop the shell from expanding *.log before find sees it.
3. -mtime +7 keeps files modified more than 7 full days ago.
4. -print0 outputs the file names separated by a null character instead of a new line, so names with spaces don't break.
5. xargs -0 reads those null-separated names and passes them to gzip in batches.
6. gzip compresses each file in place: app.log becomes app.log.gz and the original is removed.
Things to know:
- It also matches folders named something.log. Add -type f after find . to match files only.
- If a program still writes to one of these logs, compressing it can lose new lines. Stop the program or use your log rotation tool.
- Run it first with -print instead of -print0 | xargs -0 gzip to see which files it will touch.
Example 3: inputCode to explain: useEffect(() => {
const id = setInterval(() => setCount(c => c + 1), 1000);
return () => clearInterval(id);
}, []);
Your experience: Experienced developer, new to this language
Anything specific you want to understand? Why c => c + 1 instead of count + 1?
Example 3: outputWhat it does:
When this component first appears on screen, it starts a timer that adds 1 to count every second, and it stops the timer when the component is removed.
Step by step:
1. useEffect(() => { ... }, []) runs the code inside once, after the component first renders. The empty array means "don't run this again on later renders".
2. setInterval(..., 1000) calls a function every 1,000 milliseconds and returns an id for that timer.
3. setCount(c => c + 1) updates count using the latest value. This matters: because the effect only runs once, writing setCount(count + 1) would always use the count from the first render and get stuck at 1.
4. return () => clearInterval(id) is the cleanup. React runs it when the component unmounts, so the timer doesn't keep running in the background.
Things to know:
- In development with React Strict Mode, React mounts, cleans up and remounts once on purpose, so you may see the effect run twice. The cleanup is what keeps that from creating two timers.
- Browsers slow down timers in background tabs, so count can fall behind real seconds. Store a start time and compute elapsed time if accuracy matters.
Tips for better results
- Ask your specific question. "Why c => c + 1?" gets a direct answer inside the walkthrough instead of a general tour.
- Pick your real level. Explanations for new coders define every term; explanations for experienced developers skip straight to the gotchas.
- Paste the helper functions too. Without them the explainer can only guess what they do, and it will say so.
- Use it on code before you run it. Explaining a command you found online first is how you avoid deleting the wrong files.
FAQ
Is this code explainer free?
Yes. Enter your email once to use it (you'll also get Something Big, our free weekly AI newsletter, and you can unsubscribe anytime). There's no account and no credit card.
Which languages can it explain?
Most languages and formats: Python, JavaScript and TypeScript, SQL, Bash, Java, C#, Go, Ruby, PHP, Rust, regex, Excel formulas and config files such as YAML.
Can a beginner use it?
Yes. Choose New to coding and it defines each term the first time it comes up and explains why the code is written the way it is, not just what each line does.
Does it run my code?
No. It reads the code and explains it. If the code calls functions you didn't paste, it says what they probably do and marks that as a guess.
More free AI tools
Related prompts
Prefer to use ChatGPT or Claude directly? These free prompts do similar jobs.