Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


util.inspect short arrays still end up being distributed on new lines #5039

FTPlus opened this Issue · 1 comment

2 participants


When using util.inspect with colored output relatively small arrays and objects still end up on multiple lines. I guess this is caused by the fact that the color-codes are also included in the line width calculation.

example case:

 // Ends up on a single line as intended:
console.log(require('util').inspect([1,2,3,4,5,6], {colors: false}))
// Is split up over multiple lines:
console.log(require('util').inspect([1,2,3,4,5,6], {colors: true})) 

It's not really a vital problem but it makes printing larges objects much more readable. Maybe a regexp to strip out the color-codes when calculating the line width would do the trick?


Possibly. Extremely low priority issue but patches are welcome. :-)

@bnoordhuis bnoordhuis closed this issue from a commit
@kustosz kustosz util: fix util.inspect() line width calculation
Have the formatter filter out vt100 color codes when calculating the
line width. Stops it from unnecessarily splitting strings over multiple

Fixes #5039.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.