← All Tools

🧹 Log Context Trimmer

Collapse repeated noise, normalize volatile machine details, and keep first/last context plus likely root-cause lines before sending logs to an LLM or teammate.

Heuristic compaction, not a diagnosis

  • Preserves unique error lines and separately lists likely root-cause markers such as Traceback, Caused by, FAILED, and AssertionError.
  • Normalizes volatile timestamps, PIDs, memory addresses, and temporary paths so repeated logs diff cleaner.
  • Shows before/after characters and estimated tokens saved.
  • It does not prove root cause or execute logs; review the trimmed output before deleting source context.
Runs in your browser

Log trimming runs locally in your browser. Logs can contain secrets, hostnames, tokens, paths, and customer data; review before sharing or using the API.

What this tool does

Log Context Trimmer converts noisy logs and stack traces into shorter, agent-ready debugging context.

Why it is useful

It reduces token spend and repeated manual cleanup while preserving head/tail context and likely failure lines.

How it works

The shared core strips ANSI codes, normalizes volatile details, collapses repeated lines, keeps configurable head/tail context, and appends likely root-cause candidates.

Best input

Paste a complete CI failure, server error, or stack trace. Keep the original log until the bug is understood.

Debugging tip

Use the JSON summary for reproducible counts and root-cause candidates when handing logs to another agent.

Privacy note

Browser use is local; avoid pasting secrets into the API route unless you explicitly accept server submission.

Important limitation

The root-cause list is heuristic. A missing marker does not mean the log is safe or the failure is understood.

Quick answers

Will it remove secrets?

No. It normalizes some volatile machine details but is not a secret scanner.

Can it drop important lines?

It preserves selected context and root-cause candidates, but you should review output before discarding the original log.

API examples

Call the same deterministic core through Utilito’s compact API router. Send only data you intentionally submit to the server-side endpoint.

Try in API playground →Schema →
Trim a log with curl
curl
curl -X POST https://utilito.dev/api/run \
  -H "Content-Type: application/json" \
  -d '{"tool_id":"log-context-trimmer","input":{"input":"2026-07-08T04:12:22Z pid=421 worker started\nDownloading cache\nDownloading cache\nFAILED tests/parser.test.ts\nTraceback (most recent call last):\nAssertionError: expected 3 rows, got 2\nexit code 1","keepHead":10,"keepTail":15}}'
Trim a log from JavaScript
javascript
const res = await fetch('https://utilito.dev/api/run', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    tool_id: 'log-context-trimmer',
    input: { input: '2026-07-08T04:12:22Z pid=421 worker started\nDownloading cache\nDownloading cache\nFAILED tests/parser.test.ts\nTraceback (most recent call last):\nAssertionError: expected 3 rows, got 2\nexit code 1', keepHead: 10, keepTail: 15 }
  })
});
const data = await res.json();
console.log(data.result.output || data.result.report);
Trim a log from Python
python
import requests
payload = {
    "tool_id": "log-context-trimmer",
    "input": {"input": "2026-07-08T04:12:22Z pid=421 worker started\nDownloading cache\nDownloading cache\nFAILED tests/parser.test.ts\nTraceback (most recent call last):\nAssertionError: expected 3 rows, got 2\nexit code 1", "keepHead": 10, "keepTail": 15},
}
result = requests.post("https://utilito.dev/api/run", json=payload).json()["result"]
print(result.get("output") or result.get("report"))

Common Use Cases

Shrink CI output for an agent

Trim noisy install and retry lines while keeping the failing test and stack trace.

Normalize repeated production errors

Collapse duplicate lines and volatile timestamps before comparing incidents.

Create compact bug reports

Copy trimmed context plus JSON stats so teammates can reproduce what was removed.

LLM Token Toolkit workflow

Move from prompt counting to cost estimation, context-window budgeting, and log trimming before spending LLM tokens.

🧮Token Counter💸Prompt Cost Calculator🪟Context Window Calculator🧰Context Workbench🩹JSON Repair🎯JSON Query
View all in AI →