#1520·opentui

OpenTUI console does not interpret backslash escapes

Author: Keyboard1000n17Created Sep 20, 2026Updated Sep 20, 2026

The OpenTUI console does not interpret backslash escapes. It simply passes the string as written. This is a result of this piece of code:

typescript
  private formatArguments(args: any[]): string {
    return args
      .map((arg) => {
        if (arg instanceof Error) {
          const errorProps = arg
          return `Error: ${errorProps.message}\n` + (errorProps.stack ? `${errorProps.stack}\n` : "")
        }
        if (typeof arg === "object" && arg !== null) {
          try {
            return util.inspect(arg, { depth: 2 })
          } catch (e) {
            return String(arg)
          }
        }
        try {
          return util.inspect(arg, { depth: 2 })
        } catch (e) {
          return String(arg)
        }
      })
      .join(" ")
  }

The function uses util.inspect to log the string, which doesn't interpret backslash escapes. Its behavior can be seen here (Bun REPL):

❯ console.log(util.inspect("abcd\tefg"))
'abcd\tefg'
undefined
❯ console.log(util.inspect("foo\nbar"))
'foo\nbar'
undefined

A screenshot can be found below:

Image

This behavior is quite unhelpful, and a solution would be to use the string directly, although it might not wrap properly. It would also be nice if we could configure util.inspect by passing an object as seen on the Node.js website.