Stack trace formatter

Paste a Java, JavaScript, Python, C#, Go, Ruby or PHP stack trace and read it as a tree of exceptions and frames, with your code apart from libraries.

loading Stack trace formatter
About this tool

What is a stack trace formatter?

A stack trace is the list of function calls that were active when a program failed. It is the first thing you look at in a bug report, and also one of the hardest things to read: a Java trace from a web application can run to hundreds of lines, most of them framework code, with several Caused by: blocks nested inside each other. Logging systems make it worse by flattening the trace into one line with literal \n and \t characters, or by wrapping it in a JSON field.

This tool takes that raw text and turns it into something you can read and share. It detects the language, splits the trace into exceptions and frames, and shows each frame as a function, a file, a line and, when the runtime gives one, a column. It understands the formats of Java and other JVM languages, JavaScript (V8 in Node.js and Chrome, plus the Firefox and Safari style), Python, C# and .NET, Go, Ruby and PHP. Chains are kept: Java Caused by: and Suppressed:, the JavaScript [cause], Python's "direct cause" and "during handling" links, .NET inner exceptions marked with --->, Ruby causes and PHP Next exceptions.

Frames that belong to your code are marked apart from libraries, so the three lines that matter do not hide among eighty from a framework. Identical consecutive frames, such as a recursion that failed after thousands of calls, are folded into one line with a count. The result can be a tree, a Markdown block ready for a GitHub or GitLab issue, or JSON for a script. The text never leaves your browser.

How to use it

  1. Paste the trace. The page opens with a Java example that has a Caused by: block and a "... 23 more" line.
  2. Leave the language on automatic, or pick one if the text is too short to detect. The language appears above the input.
  3. Look at the tree. Filled dots mark your frames and light dots mark libraries. Turn on "Fold library frames" to collapse each run of library frames into one line.
  4. Open "Which frames count as libraries" to edit the list. A pattern matches when it appears in the file path or when the function name starts with it. Lines that start with re: are regular expressions. Add your own vendor folders, or remove a pattern that hides code you care about.
  5. Switch to Markdown to paste the trace in an issue, or to JSON to feed another tool. Copy, or download the file.

The filter list is remembered on this device. The trace you paste is not.

Examples

A Java trace with a cause

org.springframework.web.util.NestedServletException: Request processing failed
	at com.acme.shop.web.OrderController.create(OrderController.java:58)
Caused by: java.lang.IllegalStateException: order 4821 has no customer
	at com.acme.shop.service.OrderService.place(OrderService.java:91)
	... 23 more

The tree shows two exceptions. The ... 23 more line is kept on the second one: those frames are identical to the ones in the exception that wraps it, and Java omits them to save space.

A Python chain

Traceback (most recent call last):
  File "app.py", line 8, in run
    load("{bad")
json.decoder.JSONDecodeError: Expecting property name

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "app.py", line 17, in <module>
    run()
RuntimeError: config failed

Each traceback becomes one exception, and the second is labelled as raised from the first. A line such as [Previous line repeated 56 more times] is added to the frame above it as a repeat count.

A one-line log with escapes

TypeError: x is undefined\n    at render (/srv/app/src/ui.js:10:5)\n    at start (/srv/app/src/ui.js:20:3)

The literal \n sequences are turned into line breaks first, then the lines are parsed as JavaScript frames. If the whole line is a JSON log entry, the tool finds the field that holds the trace, for example error.stack.

A .NET inner exception

System.InvalidOperationException: Order failed ---> System.ArgumentNullException: Value cannot be null.
   at Acme.OrderService.Validate(Customer customer) in C:\src\OrderService.cs:line 42
   --- End of inner exception stack trace ---
   at Acme.OrderService.Place(Order order) in C:\src\OrderService.cs:line 25

The frames before the marker go to the inner exception and the ones after it go to the outer one, which is how .NET prints them.

Common mistakes

  • Pasting only the message. A line such as NullPointerException: name has no frames, so there is nothing to split. The tool reports that no frames were found.
  • Cutting the trace in the middle of a line. A half frame is not recognised. Copy whole lines, including the leading at.
  • A library you wrote. If your own package starts with org.apache. or lives under a folder called vendor, the default list marks it as a library. Edit the list.
  • Mixing two traces. If the text holds an unrelated trace from another language, pick the language by hand, or paste them one at a time.
  • Expecting source code. The tool only reads the text you paste. It does not fetch files, source maps or line contents, except for the source line Python prints under each frame.

Frequently asked questions

Does my stack trace leave the browser?

No. Parsing, classification and output run locally, with no network request. Traces often contain paths, user names and sometimes tokens, so check the result before you paste it into a public issue.

How does it decide the language?

It scores every line against the frame format of each language and picks the highest. A Java frame ends with a file and line in parentheses, a JavaScript frame has a path with line and column, a Python frame starts with File "...", line N, and so on. If the text is too short to tell, choose the language in the list.

What does "... 23 more" mean?

In Java it is not a loss of data. When an exception is a cause of another, the frames it shares with the enclosing trace are not printed again. The number says how many were left out.

Can I get the result as JSON?

Yes. Each exception has its relation, type, message and frames, and each frame has the function, file, line, column, repeat count and whether it is your code. To tidy that JSON further, use the JSON formatter.

How do I compare two traces?

Paste each one, copy the Markdown or text, and open the text comparison. To clean a pasted log before parsing it, the regular expression tester helps when you need to cut a log prefix.

Report a problem