# Pretty-printing small n-d arrays

**URL:** <https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200>\
**Category:** Internals & Design\
**Tags:** proposal, rfc\
**Created:** [January 22, 2026, 6:34am UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200 "2026-01-22T06:34:11Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 22, 2026, 6:34am UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/1 "2026-01-22T06:34:11Z")

</div>

I haven’t really looked at anything yet; I figured this might be small enough to be a first contribution, but I first wanted to ask if it would be welcome before I spent a bunch of time on it.

I really like the terminal-size aware printing of vectors and matrices, and I want higher dimensional arrays to be pretty like that as well. For 3, 4, 5, and 6 -d arrays, what would you say to:

```julia-auto
julia> collect(reshape(1:360, 24, 15))
24×15 Matrix{Int64}:
  1 25 49 73 97 121 145 169 193 217 241 265 289 313 337
  2 26 50 74 98 122 146 170 194 218 242 266 290 314 338
  3 27 51 75 99 123 147 171 195 219 243 267 291 315 339
  4 28 52 76 100 124 148 172 196 220 244 268 292 316 340
  5 29 53 77 101 125 149 173 197 221 245 269 293 317 341
  6 30 54 78 102 126 150 174 198 222 246 270 294 318 342
  7 31 55 79 103 127 151 175 199 223 247 271 295 319 343
  8 32 56 80 104 128 152 176 200 224 248 272 296 320 344
  9 33 57 81 105 129 153 177 201 225 249 273 297 321 345
 10 34 58 82 106 130 154 178 202 226 250 274 298 322 346
 11 35 59 83 107 131 155 179 203 227 251 275 299 323 347
 12 36 60 84 108 132 156 180 204 228 252 276 300 324 348
 13 37 61 85 109 133 157 181 205 229 253 277 301 325 349
 14 38 62 86 110 134 158 182 206 230 254 278 302 326 350
 15 39 63 87 111 135 159 183 207 231 255 279 303 327 351
 16 40 64 88 112 136 160 184 208 232 256 280 304 328 352
 17 41 65 89 113 137 161 185 209 233 257 281 305 329 353
 18 42 66 90 114 138 162 186 210 234 258 282 306 330 354
 19 43 67 91 115 139 163 187 211 235 259 283 307 331 355
 20 44 68 92 116 140 164 188 212 236 260 284 308 332 356
 21 45 69 93 117 141 165 189 213 237 261 285 309 333 357
 22 46 70 94 118 142 166 190 214 238 262 286 310 334 358
 23 47 71 95 119 143 167 191 215 239 263 287 311 335 359
 24 48 72 96 120 144 168 192 216 240 264 288 312 336 360

julia> collect(reshape(1:360, 12, 10, 3))
12×10×3 Array{Int64, 3}:
   1 13 25 37 49 61 73 85 97 109
   2 14 26 38 50 62 74 86 98 110
   3 15 27 39 51 63 75 87 99 111
   4 16 28 40 52 64 76 88 100 112
   5 17 29 41 53 65 77 89 101 113
   6 18 30 42 54 66 78 90 102 114
   7 19 31 43 55 67 79 91 103 115
   8 20 32 44 56 68 80 92 104 116
   9 21 33 45 57 69 81 93 105 117
  10 22 34 46 58 70 82 94 106 118
  11 23 35 47 59 71 83 95 107 119
  12 24 36 48 60 72 84 96 108 120
 ────────────────────────────────────────────────
 121 133 145 157 169 181 193 205 217 229
 122 134 146 158 170 182 194 206 218 230
 123 135 147 159 171 183 195 207 219 231
 124 136 148 160 172 184 196 208 220 232
 125 137 149 161 173 185 197 209 221 233
 126 138 150 162 174 186 198 210 222 234
 127 139 151 163 175 187 199 211 223 235
 128 140 152 164 176 188 200 212 224 236
 129 141 153 165 177 189 201 213 225 237
 130 142 154 166 178 190 202 214 226 238
 131 143 155 167 179 191 203 215 227 239
 132 144 156 168 180 192 204 216 228 240
 ────────────────────────────────────────────────
 241 253 265 277 289 301 313 325 337 349
 242 254 266 278 290 302 314 326 338 350
 243 255 267 279 291 303 315 327 339 351
 244 256 268 280 292 304 316 328 340 352
 245 257 269 281 293 305 317 329 341 353
 246 258 270 282 294 306 318 330 342 354
 247 259 271 283 295 307 319 331 343 355
 248 260 272 284 296 308 320 332 344 356
 249 261 273 285 297 309 321 333 345 357
 250 262 274 286 298 310 322 334 346 358
 251 263 275 287 299 311 323 335 347 359
 252 264 276 288 300 312 324 336 348 360

julia> collect(reshape(1:360, 8, 3, 5, 3))
8×3×5×3 Array{Int64, 4}:
   1 9 17 │ 121 129 137 │ 241 249 257
   2 10 18 │ 122 130 138 │ 242 250 258
   3 11 19 │ 123 131 139 │ 243 251 259
   4 12 20 │ 124 132 140 │ 244 252 260
   5 13 21 │ 125 133 141 │ 245 253 261
   6 14 22 │ 126 134 142 │ 246 254 262
   7 15 23 │ 127 135 143 │ 247 255 263
   8 16 24 │ 128 136 144 │ 248 256 264
 ──────────────┼───────────────┼──────────────
  25 33 41 │ 145 153 161 │ 265 273 281
  26 34 42 │ 146 154 162 │ 266 274 282
  27 35 43 │ 147 155 163 │ 267 275 283
  28 36 44 │ 148 156 164 │ 268 276 284
  29 37 45 │ 149 157 165 │ 269 277 285
  30 38 46 │ 150 158 166 │ 270 278 286
  31 39 47 │ 151 159 167 │ 271 279 287
  32 40 48 │ 152 160 168 │ 272 280 288
 ──────────────┼───────────────┼──────────────
  49 57 65 │ 169 177 185 │ 289 297 305
  50 58 66 │ 170 178 186 │ 290 298 306
  51 59 67 │ 171 179 187 │ 291 299 307
  52 60 68 │ 172 180 188 │ 292 300 308
  53 61 69 │ 173 181 189 │ 293 301 309
  54 62 70 │ 174 182 190 │ 294 302 310
  55 63 71 │ 175 183 191 │ 295 303 311
  56 64 72 │ 176 184 192 │ 296 304 312
 ──────────────┼───────────────┼──────────────
  73 81 89 │ 193 201 209 │ 313 321 329
  74 82 90 │ 194 202 210 │ 314 322 330
  75 83 91 │ 195 203 211 │ 315 323 331
  76 84 92 │ 196 204 212 │ 316 324 332
  77 85 93 │ 197 205 213 │ 317 325 333
  78 86 94 │ 198 206 214 │ 318 326 334
  79 87 95 │ 199 207 215 │ 319 327 335
  80 88 96 │ 200 208 216 │ 320 328 336
 ──────────────┼───────────────┼──────────────
  97 105 113 │ 217 225 233 │ 337 345 353
  98 106 114 │ 218 226 234 │ 338 346 354
  99 107 115 │ 219 227 235 │ 339 347 355
 100 108 116 │ 220 228 236 │ 340 348 356
 101 109 117 │ 221 229 237 │ 341 349 357
 102 110 118 │ 222 230 238 │ 342 350 358
 103 111 119 │ 223 231 239 │ 343 351 359
 104 112 120 │ 224 232 240 │ 344 352 360

julia> collect(reshape(1:360, 5, 4, 3, 3, 2))
5×4×3×3×2 Array{Int64, 5}:
   1 6 11 16 │ 61 66 71 76 │ 121 126 131 136
   2 7 12 17 │ 62 67 72 77 │ 122 127 132 137
   3 8 13 18 │ 63 68 73 78 │ 123 128 133 138
   4 9 14 19 │ 64 69 74 79 │ 124 129 134 139
   5 10 15 20 │ 65 70 75 80 │ 125 130 135 140
 ───────────────────┼────────────────────┼───────────────────
  21 26 31 36 │ 81 86 91 96 │ 141 146 151 156
  22 27 32 37 │ 82 87 92 97 │ 142 147 152 157
  23 28 33 38 │ 83 88 93 98 │ 143 148 153 158
  24 29 34 39 │ 84 89 94 99 │ 144 149 154 159
  25 30 35 40 │ 85 90 95 100 │ 145 150 155 160
 ───────────────────┼────────────────────┼───────────────────
  41 46 51 56 │ 101 106 111 116 │ 161 166 171 176
  42 47 52 57 │ 102 107 112 117 │ 162 167 172 177
  43 48 53 58 │ 103 108 113 118 │ 163 168 173 178
  44 49 54 59 │ 104 109 114 119 │ 164 169 174 179
  45 50 55 60 │ 105 110 115 120 │ 165 170 175 180
 ═══════════════════╪════════════════════╪═══════════════════
 181 186 191 196 │ 241 246 251 256 │ 301 306 311 316
 182 187 192 197 │ 242 247 252 257 │ 302 307 312 317
 183 188 193 198 │ 243 248 253 258 │ 303 308 313 318
 184 189 194 199 │ 244 249 254 259 │ 304 309 314 319
 185 190 195 200 │ 245 250 255 260 │ 305 310 315 320
 ───────────────────┼────────────────────┼───────────────────
 201 206 211 216 │ 261 266 271 276 │ 321 326 331 336
 202 207 212 217 │ 262 267 272 277 │ 322 327 332 337
 203 208 213 218 │ 263 268 273 278 │ 323 328 333 338
 204 209 214 219 │ 264 269 274 279 │ 324 329 334 339
 205 210 215 220 │ 265 270 275 280 │ 325 330 335 340
 ───────────────────┼────────────────────┼───────────────────
 221 226 231 236 │ 281 286 291 296 │ 341 346 351 356
 222 227 232 237 │ 282 287 292 297 │ 342 347 352 357
 223 228 233 238 │ 283 288 293 298 │ 343 348 353 358
 224 229 234 239 │ 284 289 294 299 │ 344 349 354 359
 225 230 235 240 │ 285 290 295 300 │ 345 350 355 360

julia> collect(reshape(1:360, 5, 3, 3, 2, 2, 2))
5×3×3×2×2×2 Array{Int64, 6}:
   1 6 11 │ 46 51 56 ║ 181 186 191 │ 226 231 236
   2 7 12 │ 47 52 57 ║ 182 187 192 │ 227 232 237
   3 8 13 │ 48 53 58 ║ 183 188 193 │ 228 233 238
   4 9 14 │ 49 54 59 ║ 184 189 194 │ 229 234 239
   5 10 15 │ 50 55 60 ║ 185 190 195 │ 230 235 240
 ──────────────┼───────────────╫───────────────┼──────────────
  16 21 26 │ 61 66 71 ║ 196 201 206 │ 241 246 251
  17 22 27 │ 62 67 72 ║ 197 202 207 │ 242 247 252
  18 23 28 │ 63 68 73 ║ 198 203 208 │ 243 248 253
  19 24 29 │ 64 69 74 ║ 199 204 209 │ 244 249 254
  20 25 30 │ 65 70 75 ║ 200 205 210 │ 245 250 255
 ──────────────┼───────────────╫───────────────┼──────────────
  31 36 41 │ 76 81 86 ║ 211 216 221 │ 256 261 266
  32 37 42 │ 77 82 87 ║ 212 217 222 │ 257 262 267
  33 38 43 │ 78 83 88 ║ 213 218 223 │ 258 263 268
  34 39 44 │ 79 84 89 ║ 214 219 224 │ 259 264 269
  35 40 45 │ 80 85 90 ║ 215 220 225 │ 260 265 270
 ══════════════╪═══════════════╬═══════════════╪══════════════
  91 96 101 │ 136 141 146 ║ 271 276 281 │ 316 321 326
  92 97 102 │ 137 142 147 ║ 272 277 282 │ 317 322 327
  93 98 103 │ 138 143 148 ║ 273 278 283 │ 318 323 328
  94 99 104 │ 139 144 149 ║ 274 279 284 │ 319 324 329
  95 100 105 │ 140 145 150 ║ 275 280 285 │ 320 325 330
 ──────────────┼───────────────╫───────────────┼──────────────
 106 111 116 │ 151 156 161 ║ 286 291 296 │ 331 336 341
 107 112 117 │ 152 157 162 ║ 287 292 297 │ 332 337 342
 108 113 118 │ 153 158 163 ║ 288 293 298 │ 333 338 343
 109 114 119 │ 154 159 164 ║ 289 294 299 │ 334 339 344
 110 115 120 │ 155 160 165 ║ 290 295 300 │ 335 340 345
 ──────────────┼───────────────╫───────────────┼──────────────
 121 126 131 │ 166 171 176 ║ 301 306 311 │ 346 351 356
 122 127 132 │ 167 172 177 ║ 302 307 312 │ 347 352 357
 123 128 133 │ 168 173 178 ║ 303 308 313 │ 348 353 358
 124 129 134 │ 169 174 179 ║ 304 309 314 │ 349 354 359
 125 130 135 │ 170 175 180 ║ 305 310 315 │ 350 355 360

```

what I’m thinking is it checks if it can print on the screen, then falls back on the current method if it can’t fit everything.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [January 22, 2026, 1:01pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/2 "2026-01-22T13:01:26Z")

</div>

I can see that you’re nesting matrix slices in matrices or a trailing column (5×3×3×2×2×2 is a 2x2 matrix of 3x2 matrices of 5x3 matrices), but the 3rd and higher dimensions aren’t conventionally considered higher-order matrices so that structure wasn’t intuitive. A multidimensional array of scalars isn’t nesting anything, but typically it’s thought of as nested vectors, which is why it prints as a (labeled) column of matrix slices as a sort of compromise.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 22, 2026, 1:11pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/3 "2026-01-22T13:11:17Z")

</div>

the idea is that each boundary is a different dimension. like, vectors represent movement along one dimension by horizontal whitespace, and matrixes represent movement along another dimension by movement along vertical whitespace without moving to a different row. extending that, you get pages that you move between without changing your position on that page for movement in each dimension above that

most people would prob only use the 3-d case, where you can think of the pages being layered on top of eachother like a cube. the lines signify where you make the cut to layer things on top of eachother in a new dimension. the double-lines have higher precedence since it’s like a ‘deeper’ cut.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [January 22, 2026, 1:17pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/4 "2026-01-22T13:17:30Z")

</div>

We’re describing the same thing. Look at how the last array is a large matrix with `═╬═` borders, its elements are matrices with `─┼─` borders, and its elements in turn are the typically formatted matrices. It’s not intuitive precisely because you had to come up a new “page” arrangement, not really the design’s fault that people don’t normally think or format like this.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 22, 2026, 1:29pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/5 "2026-01-22T13:29:51Z")

</div>

as someone who codes like this sometimes (I seem to have things with 4 or 5 orthogonal properties all too often), it doesn’t feel like I’ve come up with anything “new” here. pages seems to be the default way of visualizing higher dimensions, and that is the way the manual recommends writing higher dimensional arrays as well: [Single- and multi-dimensional Arrays · The Julia Language](https://docs.julialang.org/en/v1/manual/arrays/#man-multi-dim-arrays:~:text=Thus%2C%20higher%2Ddimensional%20arrays%20can%20also%20be%20written%20by%20specifying%20their%20rows%20first%2C%20with%20their%20elements%20textually%20arranged%20in%20a%20manner%20similar%20to%20their%20layout)

the current method of printing is very hard for me to quickly see where higher dimensional connections are, but with this output I can tell at a glance that in that last one, 61 is neighbors with 151, but 220 is 7 steps from 276.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [January 22, 2026, 1:48pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/6 "2026-01-22T13:48:26Z")

</div>

> [@rokke](#):
>
> 220 is 7 steps from 276.

I wouldn’t add up absolute differences in indices to one “distance” like this for any multidimensional array, and if I needed to find the index that is (+4,0,+2,0,+1,0) away, I’d rather search for the numbers labelling each currently printed matrix slice instead of comparing borders. I really can’t imagine how you’re even telling that sum at a glance.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 22, 2026, 2:54pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/7 "2026-01-22T14:54:23Z")

</div>

> how to compare positions

I tried to phrase it better a couple times, but I think what I said before is the best explanation. it’s a big page above, two little pages below, and four entries below. the same way you slide up/over lines/rows for vectors and matrices, you slide up/over little pages for 3d & 4d, or up/over big pages for 5d & 6d. to me, this is significantly more intuitive than unwrapping everything into a miles-long list of tiny pages with coordinates.

for arrays which can’t be printed on one screen, I agree that having the indices as a fallback is good. it still lets you get the information that you need with a little bit of math. but having to do that math every time I want to compare numbers is a pain, while putting it in a grid makes it visually clear and easy to understand.

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [January 22, 2026, 3:56pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/8 "2026-01-22T15:56:21Z")

</div>

It looks reasonably ergonomic concept to me. I think the tiling you demo is more legible than what currently happens, at least.

At some point identifying which dimensions are which can become difficult. In your demo, the odd/even dimensions always increment vertically/horizontally, but I expect one couldn’t always adhere to that. For example, a 5x20x3x3x3 array would probably exhaust the whole horizontal space on the second dimension, so would all the higher dimensions stack vertically or would it collapse the second dimension to make room for the remaining even ones? That said, presenting \>2d arrays is always challenging and either could be an improvement.

It might just be worse (i.e., more confusing), but one could try to insert dimension keys into the borders they increment. Like

```julia-auto
               4 4
   1 9 17 │ 121 129 137 │ 241 249 257
   2 10 18 │ 122 130 138 │ 242 250 258
   3 11 19 │ 123 131 139 │ 243 251 259
   4 12 20 │ 124 132 140 │ 244 252 260
   5 13 21 │ 125 133 141 │ 245 253 261
   6 14 22 │ 126 134 142 │ 246 254 262
   7 15 23 │ 127 135 143 │ 247 255 263
   8 16 24 │ 128 136 144 │ 248 256 264
3──────────────┼───────────────┼──────────────
  25 33 41 │ 145 153 161 │ 265 273 281
  26 34 42 │ 146 154 162 │ 266 274 282
  27 35 43 │ 147 155 163 │ 267 275 283
  28 36 44 │ 148 156 164 │ 268 276 284
  29 37 45 │ 149 157 165 │ 269 277 285
  30 38 46 │ 150 158 166 │ 270 278 286
  31 39 47 │ 151 159 167 │ 271 279 287
  32 40 48 │ 152 160 168 │ 272 280 288
3──────────────┼───────────────┼──────────────
  49 57 65 │ 169 177 185 │ 289 297 305
  50 58 66 │ 170 178 186 │ 290 298 306
  51 59 67 │ 171 179 187 │ 291 299 307
  52 60 68 │ 172 180 188 │ 292 300 308
  53 61 69 │ 173 181 189 │ 293 301 309
  54 62 70 │ 174 182 190 │ 294 302 310
  55 63 71 │ 175 183 191 │ 295 303 311
  56 64 72 │ 176 184 192 │ 296 304 312
3──────────────┼───────────────┼──────────────
  73 81 89 │ 193 201 209 │ 313 321 329
  74 82 90 │ 194 202 210 │ 314 322 330
  75 83 91 │ 195 203 211 │ 315 323 331
  76 84 92 │ 196 204 212 │ 316 324 332
  77 85 93 │ 197 205 213 │ 317 325 333
  78 86 94 │ 198 206 214 │ 318 326 334
  79 87 95 │ 199 207 215 │ 319 327 335
  80 88 96 │ 200 208 216 │ 320 328 336
3──────────────┼───────────────┼──────────────
  97 105 113 │ 217 225 233 │ 337 345 353
  98 106 114 │ 218 226 234 │ 338 346 354
  99 107 115 │ 219 227 235 │ 339 347 355
 100 108 116 │ 220 228 236 │ 340 348 356
 101 109 117 │ 221 229 237 │ 341 349 357
 102 110 118 │ 222 230 238 │ 342 350 358
 103 111 119 │ 223 231 239 │ 343 351 359
 104 112 120 │ 224 232 240 │ 344 352 360

```

Or maybe that space would be better for labeling tiles with their indices?

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 22, 2026, 4:30pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/9 "2026-01-22T16:30:27Z")

</div>

I think committing to always having the same consistent format (vectors go down, matrices right, then down, then right etc) would help a lot with keeping it less confusing. having to constantly check which dimension is which seems like it would be taking a step in the wrong direction, even if it does allow more efficient presentation of information sometimes.

what I had in my head was to fall back to the current coordinate method if the full array ever couldn’t fit on screen, but trimming the middle out of the whole thing like how we currently do with matrices would be another option.

in our current method, you get the first two rows of every single dimension, no matter what, and I’ve blown out my 10k line history out a couple times accidentally letting a highly dimensional array display before that max repl output length check was added.

labeling the tiles feels like a good idea, but with higher dimensional arrays we’ve already got characters at a premium, so we can’t add room for an identifier at every pane; if we move your side-labels to the centers maybe that could be helpful in some cases?

```julia-auto
         1 2 3
    1 9 17 │ 121 129 137 │ 241 249 257
    2 10 18 │ 122 130 138 │ 242 250 258
    3 11 19 │ 123 131 139 │ 243 251 259
    4 12 20 │ 124 132 140 │ 244 252 260
1 5 13 21 │ 125 133 141 │ 245 253 261
    6 14 22 │ 126 134 142 │ 246 254 262
    7 15 23 │ 127 135 143 │ 247 255 263
    8 16 24 │ 128 136 144 │ 248 256 264
  ──────────────┼───────────────┼──────────────
   25 33 41 │ 145 153 161 │ 265 273 281
   26 34 42 │ 146 154 162 │ 266 274 282
   27 35 43 │ 147 155 163 │ 267 275 283
   28 36 44 │ 148 156 164 │ 268 276 284
2 29 37 45 │ 149 157 165 │ 269 277 285
   30 38 46 │ 150 158 166 │ 270 278 286
   31 39 47 │ 151 159 167 │ 271 279 287
   32 40 48 │ 152 160 168 │ 272 280 288
  ──────────────┼───────────────┼──────────────
   49 57 65 │ 169 177 185 │ 289 297 305
   50 58 66 │ 170 178 186 │ 290 298 306
   51 59 67 │ 171 179 187 │ 291 299 307
3 52 60 68 │ 172 180 188 │ 292 300 308
   53 61 69 │ 173 181 189 │ 293 301 309
   54 62 70 │ 174 182 190 │ 294 302 310
   55 63 71 │ 175 183 191 │ 295 303 311
   56 64 72 │ 176 184 192 │ 296 304 312
  ──────────────┼───────────────┼──────────────
   73 81 89 │ 193 201 209 │ 313 321 329
   74 82 90 │ 194 202 210 │ 314 322 330
   75 83 91 │ 195 203 211 │ 315 323 331
4 76 84 92 │ 196 204 212 │ 316 324 332
   77 85 93 │ 197 205 213 │ 317 325 333
   78 86 94 │ 198 206 214 │ 318 326 334
   79 87 95 │ 199 207 215 │ 319 327 335
   80 88 96 │ 200 208 216 │ 320 328 336
  ──────────────┼───────────────┼──────────────
   97 105 113 │ 217 225 233 │ 337 345 353
   98 106 114 │ 218 226 234 │ 338 346 354
   99 107 115 │ 219 227 235 │ 339 347 355
5 100 108 116 │ 220 228 236 │ 340 348 356
  101 109 117 │ 221 229 237 │ 341 349 357
  102 110 118 │ 222 230 238 │ 342 350 358
  103 111 119 │ 223 231 239 │ 343 351 359
  104 112 120 │ 224 232 240 │ 344 352 360

```

looking at it written out maybe it’s not all that helpful, since if it’s all on one screen anyways it’s easier to just look at it. maybe if we address long output by taking the middle hunk out, it would be useful then? also, as dimension number increases, the indices on the left will start filling up more and more columns with whitespace

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 22, 2026, 4:37pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/10 "2026-01-22T16:37:12Z")

</div>

Have you thought about composing with TerminalPager.jl for outputs larger than the terminal?  
You could also compose with PrettyTables.jl to make the result look even better.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 22, 2026, 4:43pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/11 "2026-01-22T16:43:04Z")

</div>

if I’m contributing to base, I would assume I can’t use packages since that would introduce a loop.

I was thinking more about making a kinder default than building something perfect

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 22, 2026, 7:55pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/12 "2026-01-22T19:55:48Z")

</div>

yeah, I think I like without the indices at the sides better, since that would get even more confusing if you have multiple panes you need to display, like this:

```julia-auto
julia> collect(reshape(1:2^8, fill(2,8)...))
2×2×2×2×2×2×2×2 Array{Int64, 8}:
[:, :, :, :, :, :, 1, 1] =
  1 3 │ 9 11 ║ 33 35 │ 41 43
  2 4 │ 10 12 ║ 34 36 │ 42 44
 ───────┼────────╫────────┼───────
  5 7 │ 13 15 ║ 37 39 │ 45 47
  6 8 │ 14 16 ║ 38 40 │ 46 48
 ═══════╪════════╬════════╪═══════
 17 19 │ 25 27 ║ 49 51 │ 57 59
 18 20 │ 26 28 ║ 50 52 │ 58 60
 ───────┼────────╫────────┼───────
 21 23 │ 29 31 ║ 53 55 │ 61 63
 22 24 │ 30 32 ║ 54 56 │ 62 64

[:, :, :, :, :, :, 2, 1] =
 65 67 │ 73 75 ║ 97 99 │ 105 107
 66 68 │ 74 76 ║ 98 100 │ 106 108
 ───────┼────────╫──────────┼─────────
 69 71 │ 77 79 ║ 101 103 │ 109 111
 70 72 │ 78 80 ║ 102 104 │ 110 112
 ═══════╪════════╬══════════╪═════════
 81 83 │ 89 91 ║ 113 115 │ 121 123
 82 84 │ 90 92 ║ 114 116 │ 122 124
 ───────┼────────╫──────────┼─────────
 85 87 │ 93 95 ║ 117 119 │ 125 127
 86 88 │ 94 96 ║ 118 120 │ 126 128

[:, :, :, :, :, :, 1, 2] =
 129 131 │ 137 139 ║ 161 163 │ 169 171
 130 132 │ 138 140 ║ 162 164 │ 170 172
 ─────────┼──────────╫──────────┼─────────
 133 135 │ 141 143 ║ 165 167 │ 173 175
 134 136 │ 142 144 ║ 166 168 │ 174 176
 ═════════╪══════════╬══════════╪═════════
 145 147 │ 153 155 ║ 177 179 │ 185 187
 146 148 │ 154 156 ║ 178 180 │ 186 188
 ─────────┼──────────╫──────────┼─────────
 149 151 │ 157 159 ║ 181 183 │ 189 191
 150 152 │ 158 160 ║ 182 184 │ 190 192

[:, :, :, :, :, :, 2, 2] =
 193 195 │ 201 203 ║ 225 227 │ 233 235
 194 196 │ 202 204 ║ 226 228 │ 234 236
 ─────────┼──────────╫──────────┼─────────
 197 199 │ 205 207 ║ 229 231 │ 237 239
 198 200 │ 206 208 ║ 230 232 │ 238 240
 ═════════╪══════════╬══════════╪═════════
 209 211 │ 217 219 ║ 241 243 │ 249 251
 210 212 │ 218 220 ║ 242 244 │ 250 252
 ─────────┼──────────╫──────────┼─────────
 213 215 │ 221 223 ║ 245 247 │ 253 255
 214 216 │ 222 224 ║ 246 248 │ 254 256

```

my current thinking: if all 6d panes are smaller than the screen, output 6d panes like above. if one of them doesn’t fit, fall back to 4d panes. if one of those doesn’t fit, fall back to current behavior.

I’m also thinking only add 2 dimensions at a time. the initial proposal here for `collect(reshape(1:360, 12, 10, 3))` doesn’t really change the format except for deleting the coordinates, so it’s not all that helpful. so `collect(reshape(1:360, 12, 10, 3))` would be 2d panes, and `collect(reshape(1:360, 5, 4, 3, 3, 2))` would be 4d panes.

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [January 22, 2026, 7:59pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/13 "2026-01-22T19:59:22Z")

</div>

FYI: [Proposal for printing arrays of 3-4 dimensions · Issue #41176 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/41176)

(rather stale discussion, but just for reference)

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 24, 2026, 9:18pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/14 "2026-01-24T21:18:43Z")

</div>

huh. apparently, if your screen is thinner than the two rows of a 2x2 matrix, it’ll print both rows anyways but also print the ellipsis as if it was removing stuff for you:

```julia-auto
julia> [[a+b+c+d+e for a=1:2, b=1:2, c=1:2] for d=1:2, e=1:2]
2×2 Matrix{Array{Int64, 3}}:
 [5 6; 6 7;;; 6 7; 7 8] … [6 7; 7 8;;; 7 8; 8 9]
 [6 7; 7 8;;; 7 8; 8 9] [7 8; 8 9;;; 8 9; 9 10]

```

also, re-using `print_nd` for `show` is clever, but not helpful when there’s something to really show:

```julia-auto
julia> [[a+b+c+d+e for a=1:5, b=1:5, c=1:5] for d=1:2, e=1:2]
2×2 Matrix{Array{Int64, 3}}:
 [5 6 … 8 9; 6 7 … 9 10; … ; 8 9 … 11 12; 9 10 … 12 13;;; 6 7 … 9 10; 7 8 … 10 11; … ; 9 10 … 12 13; 10 11 … 13 14;;; 7 8 … 10 11; 8 9 … 11 12; … ; 10 11 … 13 14; 11 12 … 14 15;;; 8 9 … 11 12; 9 10 … 12 13; … ; 11 12 … 14 15; 12 13 … 15 16;;; 9 10 … 12 13; 10 11 … 13 14; … ; 12 13 … 15 16; 13 14 … 16 17] … [6 7 … 9 10; 7 8 … 10 11; … ; 9 10 … 12 13; 10 11 … 13 14;;; 7 8 … 10 11; 8 9 … 11 12; … ; 10 11 … 13 14; 11 12 … 14 15;;; 8 9 … 11 12; 9 10 … 12 13; … ; 11 12 … 14 15; 12 13 … 15 16;;; 9 10 … 12 13; 10 11 … 13 14; … ; 12 13 … 15 16; 13 14 … 16 17;;; 10 11 … 13 14; 11 12 … 14 15; … ; 13 14 … 16 17; 14 15 … 17 18]
 [6 7 … 9 10; 7 8 … 10 11; … ; 9 10 … 12 13; 10 11 … 13 14;;; 7 8 … 10 11; 8 9 … 11 12; … ; 10 11 … 13 14; 11 12 … 14 15;;; 8 9 … 11 12; 9 10 … 12 13; … ; 11 12 … 14 15; 12 13 … 15 16;;; 9 10 … 12 13; 10 11 … 13 14; … ; 12 13 … 15 16; 13 14 … 16 17;;; 10 11 … 13 14; 11 12 … 14 15; … ; 13 14 … 16 17; 14 15 … 17 18] [7 8 … 10 11; 8 9 … 11 12; … ; 10 11 … 13 14; 11 12 … 14 15;;; 8 9 … 11 12; 9 10 … 12 13; … ; 11 12 … 14 15; 12 13 … 15 16;;; 9 10 … 12 13; 10 11 … 13 14; … ; 12 13 … 15 16; 13 14 … 16 17;;; 10 11 … 13 14; 11 12 … 14 15; … ; 13 14 … 16 17; 14 15 … 17 18;;; 11 12 … 14 15; 12 13 … 15 16; … ; 14 15 … 17 18; 15 16 … 18 19]

```

what if we did

```julia-auto
julia> [[a+b+c+d+e for a=1:5, b=1:5, c=1:5] for d=1:2, e=1:2]
2×2 Matrix{Array{Int64, 3}}:
 (5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3})
 (5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3})

```

for things that don’t fit across the screen?

I think that would imply

```julia-auto
julia>
julia> [[[a+b+c+d+e for a=1:5, b=1:5, c=1:5] for d=1:2, e=1:2] for f=1:2, g=1:2]
2×2 Matrix{Matrix{Array{Int64, 3}}}:
 [(5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3}); (5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3})] [(5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3}); (5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3})]
 [(5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3}); (5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3})] [(5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3}); (5×5×5 Array{Int64, 3}) (5×5×5 Array{Int64, 3})]
julia>

```

for wide screens and

```julia-auto
julia> [[[a+b+c+d+e for a=1:5, b=1:5, c=1:5] for d=1:2, e=1:2] for f=1:2, g=1:2]
2×2 Matrix{Matrix{Array{Int64, 3}}}:
 (2×2 Matrix{Array{Int64, 3}}) (2×2 Matrix{Array{Int64, 3}})
 (2×2 Matrix{Array{Int64, 3}}) (2×2 Matrix{Array{Int64, 3}})

```

for small screens.

I think that’s safe because tuples have commas, and datatypes have no size next to them:

```julia-auto
julia> [(Matrix{Array{Int64, 3}},) for a=1:2, b=1:2]
2×2 Matrix{Tuple{DataType}}:
 (Matrix{Array{Int64, 3}},) (Matrix{Array{Int64, 3}},)
 (Matrix{Array{Int64, 3}},) (Matrix{Array{Int64, 3}},)

julia> [(Matrix{Array{Int64, 3}}) for a=1:2, b=1:2]
2×2 Matrix{DataType}:
 Matrix{Array{Int64, 3}} Matrix{Array{Int64, 3}}
 Matrix{Array{Int64, 3}} Matrix{Array{Int64, 3}}

```

---

<div class="post-metadata">

**Author:** ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Post date:** [January 27, 2026, 3:56pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/15 "2026-01-27T15:56:59Z")

</div>

The 3D and 4D arrays look good to me. For 5D and 6D, `═══` between numbers are more obscure and gradually loose their distinction when arrays are large. I would rather have large emtpy spaces between them to distinguish boundary separations.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 28, 2026, 1:36am UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/16 "2026-01-28T01:36:07Z")

</div>

you can also see [julep: robust array printing · Issue #60824 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/60824) for the current version of the proposal. I went back to 2 lines of separation with an explicit label for 3d, 5d, and \>7d, for the same reason you were pointing out here.

additionally, the 6d arrays would only appear if the entire thing fits on the screen without any wrapping, additionally, I was also thinking that since julia is becoming color-able, that both sets of borders could become a `comment grey` color, and the `═══` borders could be bold

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 28, 2026, 3:30am UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/17 "2026-01-28T03:30:08Z")

</div>

another potential method could be

```julia-auto
julia> collect(reshape(1:360, 5, 3, 3, 2, 2, 2))
5×3×3×2×2×2 Array{Int64, 6}:
   1 6 11 │ 46 51 56 ││ 181 186 191 │ 226 231 236
   2 7 12 │ 47 52 57 ││ 182 187 192 │ 227 232 237
   3 8 13 │ 48 53 58 ││ 183 188 193 │ 228 233 238
   4 9 14 │ 49 54 59 ││ 184 189 194 │ 229 234 239
   5 10 15 │ 50 55 60 ││ 185 190 195 │ 230 235 240
 ──────────────┼───────────────┤├───────────────┼──────────────
  16 21 26 │ 61 66 71 ││ 196 201 206 │ 241 246 251
  17 22 27 │ 62 67 72 ││ 197 202 207 │ 242 247 252
  18 23 28 │ 63 68 73 ││ 198 203 208 │ 243 248 253
  19 24 29 │ 64 69 74 ││ 199 204 209 │ 244 249 254
  20 25 30 │ 65 70 75 ││ 200 205 210 │ 245 250 255
 ──────────────┼───────────────┤├───────────────┼──────────────
  31 36 41 │ 76 81 86 ││ 211 216 221 │ 256 261 266
  32 37 42 │ 77 82 87 ││ 212 217 222 │ 257 262 267
  33 38 43 │ 78 83 88 ││ 213 218 223 │ 258 263 268
  34 39 44 │ 79 84 89 ││ 214 219 224 │ 259 264 269
  35 40 45 │ 80 85 90 ││ 215 220 225 │ 260 265 270
 ──────────────┴───────────────┘└───────────────┴──────────────
 ──────────────┬───────────────┐┌───────────────┬──────────────
  91 96 101 │ 136 141 146 ││ 271 276 281 │ 316 321 326
  92 97 102 │ 137 142 147 ││ 272 277 282 │ 317 322 327
  93 98 103 │ 138 143 148 ││ 273 278 283 │ 318 323 328
  94 99 104 │ 139 144 149 ││ 274 279 284 │ 319 324 329
  95 100 105 │ 140 145 150 ││ 275 280 285 │ 320 325 330
 ──────────────┼───────────────┤├───────────────┼──────────────
 106 111 116 │ 151 156 161 ││ 286 291 296 │ 331 336 341
 107 112 117 │ 152 157 162 ││ 287 292 297 │ 332 337 342
 108 113 118 │ 153 158 163 ││ 288 293 298 │ 333 338 343
 109 114 119 │ 154 159 164 ││ 289 294 299 │ 334 339 344
 110 115 120 │ 155 160 165 ││ 290 295 300 │ 335 340 345
 ──────────────┼───────────────┤├───────────────┼──────────────
 121 126 131 │ 166 171 176 ││ 301 306 311 │ 346 351 356
 122 127 132 │ 167 172 177 ││ 302 307 312 │ 347 352 357
 123 128 133 │ 168 173 178 ││ 303 308 313 │ 348 353 358
 124 129 134 │ 169 174 179 ││ 304 309 314 │ 349 354 359
 125 130 135 │ 170 175 180 ││ 305 310 315 │ 350 355 360

```

actually yeah, I think this is better

or maybe even

```julia-auto
 julia> collect(reshape(1:360, 5, 3, 3, 2, 2, 2))
5×3×3×2×2×2 Array{Int64, 6}:
   1 6 11 │ 46 51 56 ┃┃ 181 186 191 │ 226 231 236
   2 7 12 │ 47 52 57 ┃┃ 182 187 192 │ 227 232 237
   3 8 13 │ 48 53 58 ┃┃ 183 188 193 │ 228 233 238
   4 9 14 │ 49 54 59 ┃┃ 184 189 194 │ 229 234 239
   5 10 15 │ 50 55 60 ┃┃ 185 190 195 │ 230 235 240
 ──────────────┼───────────────┨┠───────────────┼──────────────
  16 21 26 │ 61 66 71 ┃┃ 196 201 206 │ 241 246 251
  17 22 27 │ 62 67 72 ┃┃ 197 202 207 │ 242 247 252
  18 23 28 │ 63 68 73 ┃┃ 198 203 208 │ 243 248 253
  19 24 29 │ 64 69 74 ┃┃ 199 204 209 │ 244 249 254
  20 25 30 │ 65 70 75 ┃┃ 200 205 210 │ 245 250 255
 ──────────────┼───────────────┨┠───────────────┼──────────────
  31 36 41 │ 76 81 86 ┃┃ 211 216 221 │ 256 261 266
  32 37 42 │ 77 82 87 ┃┃ 212 217 222 │ 257 262 267
  33 38 43 │ 78 83 88 ┃┃ 213 218 223 │ 258 263 268
  34 39 44 │ 79 84 89 ┃┃ 214 219 224 │ 259 264 269
  35 40 45 │ 80 85 90 ┃┃ 215 220 225 │ 260 265 270
 ━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛┗━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━
 ━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓┏━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━
  91 96 101 │ 136 141 146 ┃┃ 271 276 281 │ 316 321 326
  92 97 102 │ 137 142 147 ┃┃ 272 277 282 │ 317 322 327
  93 98 103 │ 138 143 148 ┃┃ 273 278 283 │ 318 323 328
  94 99 104 │ 139 144 149 ┃┃ 274 279 284 │ 319 324 329
  95 100 105 │ 140 145 150 ┃┃ 275 280 285 │ 320 325 330
 ──────────────┼───────────────┨┠───────────────┼──────────────
 106 111 116 │ 151 156 161 ┃┃ 286 291 296 │ 331 336 341
 107 112 117 │ 152 157 162 ┃┃ 287 292 297 │ 332 337 342
 108 113 118 │ 153 158 163 ┃┃ 288 293 298 │ 333 338 343
 109 114 119 │ 154 159 164 ┃┃ 289 294 299 │ 334 339 344
 110 115 120 │ 155 160 165 ┃┃ 290 295 300 │ 335 340 345
 ──────────────┼───────────────┨┠───────────────┼──────────────
 121 126 131 │ 166 171 176 ┃┃ 301 306 311 │ 346 351 356
 122 127 132 │ 167 172 177 ┃┃ 302 307 312 │ 347 352 357
 123 128 133 │ 168 173 178 ┃┃ 303 308 313 │ 348 353 358
 124 129 134 │ 169 174 179 ┃┃ 304 309 314 │ 349 354 359
 125 130 135 │ 170 175 180 ┃┃ 305 310 315 │ 350 355 360

```

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [January 28, 2026, 5:58pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/18 "2026-01-28T17:58:56Z")

</div>

I like that! I think it might look even more compelling by completing the outermost edges of all the boxes. Somehow that makes it easier for me to imagine stacking the matrices in the third and fourth dimensions. I’m still not as convinced about the need for the fifth and sixth dimensions, but the thick borders with the whitespace separation looks quite good too.

I can also imagine how you could similarly elide whole panes (or _interiors_ of some panes) without needing to resort to the slicing pseudo-syntax of `[:,:,i] = ...`.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 28, 2026, 11:45pm UTC](https://discourse.julialang.org/t/pretty-printing-small-n-d-arrays/135200/19 "2026-01-28T23:45:53Z")

</div>

elision of panes would be an orthogonal problem to the slice labels. the labels are always for dimensions we are not displaying graphically, so to smoshing everything together and putting some ellipsis in there would just make it more confusing.

in some very specific situations I could see elision of sections in a pane as being useful, but eliding tiles in a section would be very visually confusing.

I don’t want outer borders because I really like the “dim = 2\*# lines + (1 if down, 2 if right)” thing. plus, an outer border isn’t dividing any two specific panes, so it would be ambiguous as to which border style it should use.
