[Question]
  [
Given a 2-dimensional [jagged array](https://en.wikipedia.org/wiki/Jagged_array) and a fill value, pad the array in both dimensions with the fill value to ensure that it is square and not jagged (i.e., all rows are the same length, and that length is the same as the number of rows).
The fill values should always be added to the "edges", which may be the start or the end, but not in the middle.
For example, with the fill value `8`, this array:
```
[[1, 5, 3],
 [4, 5],
 [1, 2, 2, 5]]
```
could become:
```
[[1, 5, 3, 8],
 [4, 5, 8, 8],
 [1, 2, 2, 5],
 [8, 8, 8, 8]]
```
Here is another valid output:
```
[[8, 8, 8, 8],
 [8, 1, 5, 3],
 [8, 4, 5, 8],
 [1, 2, 2, 5]]
```
However, the padding should be minimal: the size of the output square should be equal to the maximum of the length of the rows and the number of rows. For example, this is not a valid output for the input above:
```
[[1, 5, 3, 8, 8],
 [4, 5, 8, 8, 8],
 [1, 2, 2, 5, 8],
 [8, 8, 8, 8, 8],
 [8, 8, 8, 8, 8]]
```
## More test cases
All using fill value `0` for simplicity.
```
Input:
[]
Output:
[]
```
```
Input:
[[],
 []]
Output:
[[0, 0],
 [0, 0]]
```
```
Input:
[[5]]
Output:
[[5]]
```
```
Input:
[[0, 0],
 [0],
 [0, 0, 0]]
Output:
[[0, 0, 0],
 [0, 0, 0],
 [0, 0, 0]]
```
```
Input:
[[1, 2, 3, 4]]
Output:
[[1, 2, 3, 4],
 [0, 0, 0, 0],
 [0, 0, 0, 0],
 [0, 0, 0, 0]]
```
```
Input:
[[1],
 [2],
 [3],
 [4, 5]]
Output:
[[1, 0, 0, 0],
 [2, 0, 0, 0],
 [3, 0, 0, 0],
 [4, 5, 0, 0]]
```
## Rules
* The array's elements and the fill value can be of whatever type or set of values you like, as long as there are at least two distinct possibilities. For example, you could use characters, where the array is a multi-line string (where each line is a row), or you could restrict the values to single digits...
* [Standard loopholes](https://codegolf.meta.stackexchange.com/q/1061) are forbidden
* [Standard I/O rules](https://codegolf.meta.stackexchange.com/q/2447) apply
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins
  
[Answer]
# [Haskell](https://www.haskell.org/), 67 bytes
```
m%v|let l?x=take(maximum$length<$>(1<$m):m)$l++repeat x=(?v)<$>m?[]
```
[Try it online!](https://tio.run/##TU9LCsIwEN17illESGgEbSuItPYEniAECSXW0kwJTSxdeHZjUhcKw8y8D/N5KDdoY0LA7fwy2oNpltqrQVNUS49PJEaPnX9U5EIPFUF2RkZMlk3aauVhqWkzsyhiI2Tw2vlbq5x2UIOgQhw4HDkUkoMoY5tqpPI1jjLCE@MQfUlIcP@FX0/BofwnkylP6TdvVeVmg6of40pU9gp26kcPIv4DL6DIZwbVDn6nyfBu70Z1Luxaaz8 "Haskell – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 25 bytes
```
4 :'y([{.!.x&>{.)~>./$>y'
```
[Try it online!](https://tio.run/##y/r/P81Wz0TBSr1SI7paT1GvQs2uWk@zzk5PX8WuUv1/ha2eQqIVV2pyRr5CBYSyUEiDMdV1dXXVubgginSIUmejY2VKhDIDawUDKKFgQIyxCoYKRgrGCiZEqDW0NrQ2tjZRwOKO/wA "J – Try It Online")
*Note: -3 off TIO for `f=.`*
Note that in J ragged arrays must be boxed.
This was surprisingly hard considering that J auto fills ragged arrays by default. Unfortunately, the default behavior is not quite enough for what's needed in this challenge.
## how
We take the fill as the left arg `x` and the input arrays as the right arg `y`, and use an explicit (rather than tacit) verb because the fit conjunction `!.` required to specify fill requires a value or named variable.
* `>./$>y` - The max `>./` of the dimensions `$` of the opened input `>y`. We'll use this as the left argument of the main verb.
* `([ {.!.x&> {.)` The main verb, consisting of a fork whose right tine `{.` expands the boxed input to the required dimension by filling it with blank boxes. This handles what will ultimately become the "vertical expansion".
* `{.!.x&>` For each box `&>` (the original input, plus the empty expansions produced in the previous step), take `{.` the required length, filling missing items with the specified fill `!.x`. This handles the "horizontal expansion".
[Answer]
# [K (ngn/k)](https://bitbucket.org/ngn/k), ~~21~~ 19 bytes
```
{y^x .!'2#|/#'x,,x}
```
[Try it online!](https://tio.run/##NYwxCsMwFEOvIpPB3/CbfjsxlOouHZMhkNmh7dndOKZokNBD2m77ute6PN/Hq2B0Pg2f@@CLavnWBaMXkYiMiTMyI9KpHPgIFAm0Zs7orGfV3DuDUY2n4Y/adsLcuUZqol6vjYf6Aw "K (ngn/k) – Try It Online")
* `|/#'x,,x` get the size of the output (i.e. the maximum of the count of each row, and of the number of rows)
* `!'2#` build a list of two copies of 0..size (e.g. `(0 1 2 3;0 1 2 3)`)
* `x .` dot-apply into the input (out of bound accesses result in `0N`s)
* `y^` replace nulls with the fill number
[Answer]
# [R](https://www.r-project.org/), ~~80~~ ~~90~~ ~~93~~ 88 bytes
*Edit: -5 bytes thanks to Kirill L., but only after +10 bytes to fix bug, and +3 more bytes after belatedly realising that the fill-value should be given as input...*
```
function(l,f,m=matrix(f,d<-max(0,seq(l),lengths(l)),d)){for(i in l)m[F<-F+1,seq(i)]=i;m}
```
[Try it online!](https://tio.run/##NY69CsIwFEZ3n6LjvXgLRs1QbNa@hDiUtolXklTzAwXx2WMtyDecM5zhCyX7R2/MNKqisx8Szx4saXLK9SnwAprGtnb9AgeK0wsskp28Sfe4KtKI@NZzAK7YVxbdtWvrbi@2lPGm@OI@hf0zJ2U5JhhAkKQT0gBnkj8IOq6TiLv/E9h6ahosXw "R – Try It Online")
[Answer]
# [JQ](https://stedolan.github.io/jq/), 49 bytes
Takes input as an array of `[array, fill-element]`, where the array can hold any non-null type.
```
.[1]as$a|.[0]|transpose|transpose|map(map(.//$a))
EXPLANATION:
.[1]as$a|  # input array's second argument is in variable a
         .[0]|  # the first argument
              transpose|  # transposed, automatically placing null as a fill element
                        transpose|  # back to normal
                                  map(      # for each row
                                      map(  # for each element
                                          .//$a  # if it's null, the fill element, else it.
# // is like or in other languages, . means "it" or "it unchanged"
```
<https://jqplay.org/s/8ADEt9WJGL>
[Answer]
# JavaScript (ES6), 92 bytes
Expects `(array)(value)`, where `array` contains positive integers (or any other truthy values).
```
a=>v=>[a,...a].sort((a,b)=>b.length-a.length)[0].map((_,y,A)=>A.map((_,x)=>(a[y]||0)[x]||v))
```
[Try it online!](https://tio.run/##fY7NCoMwEITvPkWOWViD9Qd6UfA5QiirtbbFGlERBd89TY2FHqSwMDvLN8M@aaKh7B/d6Lf6WplbaijNpjSThEIIUmLQ/cg5YQFpVoimauvx7tO@gAyUeFHH@QUXzC2Sf@1sDSe5qHUNQM5WJgBT6nbQTSUaXfMblx5j8oQsQRYp/JjYGrfZc7hNojwF/AzgHYQduxHBMeF6ImTxX8oVhU5@n9lD5g0 "JavaScript (Node.js) – Try It Online")
### Commented
```
a =>                  // a[] = jagged array
v =>                  // v = fill value
[a, ...a]             // build an array consisting of the jagged array itself
                      // followed by each of its rows
.sort((a, b) =>       // sort this array ...
  b.length - a.length //   ... from longest to shortest entry
)[0]                  // and keep the longest one
.map((_, y, A) =>     // for each row at position y in this array A[]:
  A.map((_, x) =>     //   for each entry at position x in A[]:
    (a[y] || 0)[x]    //     attempt to get the value at (x, y) in a[]
    || v              //     if it fails, use the fill value instead
  )                   //   end of inner map()
)                     // end of outer map()
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 26 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ([SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set"))
Anonymous infix lambda, taking fill as left argument and array as right argument.
```
{g←1⌷∘↑↑⍮∘⍉↑⋄⍺@(⍸~g=⍨⍵)g⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/vzr9UdsEw0c92x91zHjUNhGEeteB2L2dIHZ3y6PeXQ4aj3p31KXbPupd8ah3q2Y6kKj9nwbU96i371FX86PeNY96txxabwLS0Dc1OMgZSIZ4eAZzZYHU9E31Cvb3Axs/OQ1EQQT@q@vq6iq4efr4KIR7hngoGCgA@epcBgpZCurR0YY6CqY6CsaxOgrRJkAmiAYKGYGRaWysOhfM2LbJQJ1pQGwAdIMBTDtIPUgVlGuKxDbQUTAASUMIIAfEj0W2GGiFsY6CCbIgSK0RiEC4CCiL5gMLC4gXgDTJfgDqQXgCZgDMFzC@KTIHlz@QbEfyCFwUq08A "APL (Dyalog Extended) – Try It Online")
`{`…`}` dfn; left argument (fill) is `⍺`, right argument (array) is `⍵`
 `g←` define `g` as a tacit function:
  `1⌷∘` the first layer of the 3D array that consist of
   `↑` the 3D array consisting of the following two layers, padded with 0s:
  `↑⍮∘⍉` the 2D array consisting of the given rows, padded with 0s, and the transposed…
   `↑` 2D array consisting of the given rows, padded with 0s
`⋄` then:
 `⍺@(`…`)` place fills **at** the indices given by:
  `⍸` the **ɩ**ndices where…
  `~` there are zeros (lit. NOT)…
  `g` in the fully padded version of…
  `=⍨` the array identical to the given one, but with all elements made into 1s (lit. self-equality)
 `g⍵` in the fully padded given array
[Answer]
# [APL(Dyalog Unicode)](https://dyalog.com), ~~47 37~~ 32 bytes [SBCS](https://github.com/abrudz/SBCS)
```
{⍺@((,⍳x)~⍸↑=⍨⍵)⊢(x←2/⌈/⍴↑⍵)↑↑⍵}
```
[Try it on APLgolf!](https://razetime.github.io/APLgolf/?h=AwA&c=q37Uu8tBQ0PnUe/mCs26R707HrVNtH3Uu@JR71bNR12LNCoetU0w0n/U06H/qHcLUA4sDqTArFoA&f=s1BIU3jUN9Ur2N9PPTpWncsAmR9tGKsTbRSroxBtDCJMdBRMY2PVAQ&i=AwA&r=tryAPL&l=apl-dyalog&m=dfn&n=f)
A dfn submission which takes fill element on the left, and ragged array on the right.
It calculates the indices of the existing elements and replaces everything else with the fill element.
-10, borrowing an idea from Adám's answer.
-5 from user.
[Answer]
# [Functional Bash](https://www.gnu.org/software/bash/)\*, 167 161 147 bytes
\* This is bash with the additional constraint that you can't mutate variables. 
-14 bytes thanks to pxeger
```
m=`sort -n <(awk '{print NF}' $1) <(wc -l<$1)|tail -1`
s=`seq $m`
paste -d\  $1 <(printf "`printf "$2 %.s" $s`\n%.s" $s)|sed s/^\ //|cut -d\  -f-$m
```
[Try it online!](https://tio.run/##lYw7b8JAEIT7/RUjdHC4WGzzkCgMHZRJkdaK7mJsQGDzuEMUmN/uLAmRolSORtoZjb7ZD@s2TdEPbk05M@5w9uAKSd9ed9C343lbebws7xoqDqS@ZuB9Irn2drsHx4aczPITVGnoaJ3PwasUggv9NS/QMT9BDdEduA6UM2n1TEHt8hVc@J4iDOvs4r8fcMGqbO6UZ5sDtEaNNXo9FGLTZ8nMmiizHkmyeH3D/DdCJFUbcNIWjBBR9LjiLScxhhhh/A@c4ocg@jNqPgE "Bash – Try It Online")
The two arguments are:
* `$1`: file name containing lines of input
* `$2`: The fill character
The basic approach is to get the side length of the square (stored in `m`) and then create an `m` x `m` file of the fill, `paste` it with the original file, and take `m` fields from each line.
Would love to know if there's a terser approach.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 27 bytes
```
≔⌈⊞ＯＥηＬιＬηζＩＥ…⁺ηＥζυζ…⁺ιＥζθζ
```
[Try it online!](https://tio.run/##XYu7CgMhFET7/QpLBQN5VluFbRNiLxYisgquGh8h2Z83GmGL3ObcGc4IxYNw3JRyjVHPFt75Wy95gSRH9fAy8ORCLT1UGNyknZOCGqHtV6iFFY0DCdomOPGYfvr0EUZOynlITI5t3doVg9wHGPwZejOe3ag3lkL3eACUHlgFoMeOU8cZgwtjrOxe5gs "Charcoal – Try It Online") Takes the fill as first input and the jagged array as second input, but they can be trivially reversed if necessary. Outputs using Charcoal's default array format, which is each element on a separate line with rows double-spaced from each other. Explanation:
```
≔⌈⊞ＯＥηＬιＬηζ
```
Take the length of each element of the jagged array, tack on the length of the array itself, and then take the maximum of the result.
```
ＩＥ…⁺ηＥζυζ…⁺ιＥζθζ
```
Concatenate an array of empty arrays to the jagged array, then chop to the desired length. For each element of that array, concatenate an array of the fill value, then chop to the desired length. Print the result.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ṭ`zṖ€ɗ⁺⁹
```
A dyadic Link accepting a, possibly jagged, two-dimensional array on the left and a fill value on the right which yields a square array which is filled rightwards and downwards with the fill value.
**[Try it online!](https://tio.run/##y0rNyan8///hzrUJVQ93TnvUtObk9EeNux417vx/ePnRSQ93zvj/PzraMFaHSyHaCEwag0kTHQXT2Nj/BgA "Jelly – Try It Online")** (Footer added to format the resulting array, so that one can see the empty case work.)
### How?
```
ṭ`zṖ€ɗ⁺⁹ - Link: array, A; filler, F
       ⁹ - use the right argument, F, as the right argument of:
           (seems to be required for the ⁺, below)
      ⁺  -   repeat this link twice:
     ɗ   -     last three links as a dyad - f(current A, F):
  `      -       use left (A) as both arguments of:
 ṭ       -         tack - e.g. [[1],[2,3]] -> [[1],[2,3],[[1],[2,3]]]
                   (only thing that matters is that the tacked list has the length of A)
   z      -      transpose with filler (F) -> rectangular array right-filled.
    Ṗ€    -      pop an element off of each (removing the tacked lists)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~18~~ ~~17~~ 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
2FDªIζ€¨
```
-9 bytes by porting [*@JonathanAllan*'s Jelly answer](https://codegolf.stackexchange.com/a/219050/52210), so make sure to upvote him as well!
[Try it online](https://tio.run/##yy9OTMpM/f/fyM3l0CrPc9seNa05tOL//@how1idaCMgNgZiEx3T2FguCwA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpSbKWgZF@ZUGyvpJCYlwJk63Ap@ZeWAGWAEjqVCaH/jdxcDq2KOLftUdOaQyv@1@oc2mb/PxoIDHVMdYxjdaJNdEyBpKGOERCaxsbqWMTqKERHx@oYgOlokBCUaQBiRBsgBECajHVMkASA8kZADDMXZFosAA).
**Previous 17 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) answer:**
```
Dª€gà©nи®ô¹ì²ζø®∍
```
[Try it online](https://tio.run/##yy9OTMpM/f/f5dCqR01r0g8vOLQy78KOQ@sObzm08/CaQ5vObTsM5D3q6P3/PzraMFYn2giIjYHYRMc0NpbLAgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpSbKWgZF@ZUGyvpJCYlwJk63Ap@ZeWAGWAEjqVCaFhEZH/XQ6tetS0Jv3wgkMr8y7sOLTu8JbIw2sizm07DGQ/6uj9r3Nom/3/aCAw1DHVMY7ViTbRMQWShjpGQGgaG6tjEaujEB0dq2MApqNBQlCmAYgRbYAQAGky1jFBEgDKGwExzFyQabEA).
**Explanation:**
```
2F                 # Loop 2 times:
  D                #  Duplicate the current matrix
                   #  (which will be the implicit input-matrix in the first iteration)
   ª               #  Append the matrix to itself
     ζ             #  Zip/transpose; swapping rows/columns,
    I              #  using the second input-character as filler
      €¨           #  And then remove the last item of each row
                   # (after the loop, the resulting matrix is output implicitly)
D                  # Duplicate the first (implicit) input-matrix
 ª                 # Append the matrix to itself
  €                # Map over each inner list:
   g               #  Pop and push its length
    à              # Pop and push the maximum
                   # (we now have the dimension of the output-square, which is either
                   #  equal to the amount of rows or amount of columns, whichever of
                   #  the two is larger)
     ©             # Store this maximum in variable `®` (without popping)
      n            # Square it
       и           # Repeat the second (implicit) input that amount of times as list
        ®ô         # Split it into parts of size `®`
          ¹ì       # Prepend the first input-matrix at the front
             ζ     # Zip/transpose; swapping rows/columns,
            ²      # using the second input-character as filler
              ø    # And then zip/transpose the rows/columns back
               ®∍  # Shorten the matrix to the first `®` amount of rows
                   # (after which the resulting matrix is output implicitly)
```
[Answer]
# [Python 2](https://docs.python.org/2/), 75 bytes
```
def f(M,v):n=max(map(len,M+[M]));print[(r+[v]*n)[:n]for r in(M+[[]]*n)[:n]]
```
[Try it online!](https://tio.run/##RYxLCoMwEIb3OcUsk5pFfUGxeARPMMxCqGJAxxCsbU@fToptYZjH9w@ff23TykWMt2GEUXd2Nw23S//US@/1PLDtMuzImKsPjjfUIcOdTmywYRrXAAEca/lB@lKKj8nNA@SNAvG1jv1900Yd@oiYW6gtlGQBK1nTFFR8qiY5L0p8QtN@VnikpYXqR1JcpPbXpOgN "Python 2 – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal/wiki), ~~15~~ 14 [bytes](https://github.com/somebody1234/Charcoal/wiki/Code-page)
```
ＵＯ⌈⊞ＯＥθＬιＬθηＰθ
```
Matrix-input as a list of string-rows; filler-character as string input; and output as a printed multi-line string, which is allowed based on the first rule.
[Try it online (verbose)](https://tio.run/##PYhLCoAgFAD3nSLeSsEg@kCHKGofLSwiBfOXRrd/2abFwMxsgvvNcIU4rsrogwz8kWc8yRQvMdrd82B8mpY4lve7PoIgktLfHf1C0GyIKkjrpQ7pIc4zlMCgStSJpoWF5dDBgsWtXg) or [try it online (pure)](https://tio.run/##S85ILErOT8z5///9nq3v96x/1NPxqGsekPF@z9JzO97vWXNuJ4jYcW77@z0bzu34/z86WslASUfJCIiNgdjEVClWR0HJQikWAA).
**Explanation:**
Determine the length of each row, the amount of rows, and then only leave the maximum of those combined:
```
Maximum(PushOperator(Map(q, Length(i)), Length(q)))
⌈⊞ＯＥθＬιＬθ
```
Draw a square of that size, using the second input-character as filler:
```
Oblong(..., h)
ＵＯ...η
```
Then print the first input on top of that to finish the intended result:
```
Multiprint(q)
Ｐθ
```
[Answer]
# [Scala](http://www.scala-lang.org/), 75 bytes
```
a=>p=>{val m=(a.map(_.size):+a.size).max
a.padTo(m,Seq())map(_.padTo(m,p))}
```
[Try it online!](https://tio.run/##dU/NCsIwDL7vKXJssI79CSJs4NGDJ73JkKgdTLZa3ZDh2LPPdquCotDwJd9P2lZHKqi/HM7iWMOacgmiqYU8VbBUqnXuVEC2gI247kytZJ2mECegGwNfPPQUJypOWhMrY0ZuSYrt3Sp/CFxMaGw02TjkKjptL6zkOs8QR@OLU4hdr265rAvJMmYspnwOMw4hcgfM1SzS83vQYjCcGSIyD9H5XPCTHAQOo/7P4HHwrOmNmjLs38z4mpBDZDzz3x67LLAYWozsH6Z@EOpg1z8B "Scala – Try It Online")
# [Scala](http://www.scala-lang.org/), 108 bytes
```
a=>p=>{val m=a.map(_.size)./:(a.size)(_ max _)
Seq.tabulate(m,m)((i,j)=>scala.util.Try(a(i)(j))getOrElse p)}
```
[Try it online!](https://tio.run/##fU9Na8MwDL3nV@gogfHSLxiFBHboYYexw3YbJaidOxzszEvc0a30t2d2YgbdaMHiPT29J@Ruy4b7902tth4eWDegDl41rx3cOXfMPtnAbglP6uMl1n3j12soSggkwh8dei5KV5THGLMFS8sOK9npb0XyZok8UqzA8gEqykJWet7sDXuFVlhC1KKmouziWXLvtZHP7RcyasKa6E35x3ZlOgWOTr1rdeNNgzsMe4aaCFgImJGIl@E8dImGwXR4CyLCW6LsPBzE/J84DMY8XTTkAvJk@sUgRfViZrxmJmB@xZOWTROefSqlTv0P "Scala – Try It Online")
[Answer]
# [Zsh](https://www.zsh.org/), ~~91~~ 83 bytes
```
wc<I -lL|read l w
repeat w-l
echo>>I
while read i
do<<<${(pr/l>w?l:w//$1/)i}
done<I
```
[Try it online!](https://tio.run/##HYsxCsMwDAB3vUJDhmQIbtci3KkFQ6BvMI6CDaIJrkGQNG93TbeDu9s/sS79cFQN5HCU6ZvZzyiokHljX1BHAQ5xtdaBxiSM/yLBvBJRd/RbNmL1Ljc1pruaIZ1NvZlcPSH4QvR4PdsbARrAgpf6Aw "Zsh – Try It Online")
Works character-wise, taking input from a file `I` and the first command-line argument.
This was going to be a suggestion to Jonah's [Bash answer](https://codegolf.stackexchange.com/a/219093), but it became sufficiently different that I thought I'd post it separately.
* `wc -lL` - output the number of lines and the maximum line length
* `<I` - from the file `I`
* `|read l w` - and store those values in the variables `l` and `w` respectively
* `repeat w-l` - repeat [the difference between `w` and `l`] times:
	+ `echo` - print a blank line
	+ `>>I` - append that to the file `I`
	+ this adds extra blank rows if needed; because if `w-l` is negative, the `repeat` won't execute at all
* `while read i` `do` `done<I` - for each line in `I`:
	+ `${i}` - take that line, and
	+ `(p)` - substituting in the values of `m` and `1`,
	+ `(r/l>w?l:w//$1/)` - pad on the right using the character `$1` to the length `l>w?l:w`
		- `l>w?l:w` is the maximum line length and number of lines.
	+ `<<<` - and print that line
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), ~~33 32 29~~ 10 bytes
```
2(:wJ⁰ÞṪvṪ
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=2%28%3AwJ%E2%81%B0%C3%9E%E1%B9%AAv%E1%B9%AA&inputs=%5B%5B1%5D%2C%5B2%5D%2C%5B3%5D%2C%5B4%2C5%5D%5D%0A8&header=&footer=)
Thanks to lyxal for -23 bytes.
[Answer]
# [Lua](https://www.lua.org/), ~~205~~ 187 bytes
```
load("t=".. ....."c=#t for i=1,c do c=math.max(c,#t[i])end p=io.write p'{'for i=1,c do for j=1,c do _=j==1 and p'{'p(t[i]and t[i][j]or 0)p(j==c and'}'or',')end _=i~=c and p','end p'}'")()
```
[Try it online!](https://tio.run/##VY3RCsIwDEV/JdSHthCKVfeYLxljlG5ix2bHqCiU@uu1nfhg8pDccG7u/DA5z94MggViSoGqxSwdAlz9Bo40Whg8WFpMuKnFvITFQ2hdJ8f7ACs5r56bCyOsPPI/SxXTT/Q0EWkw1VPAVdQXVdXZTl1hj3IVBbIV4on7jSPfQ3py7@@5eJHvuQVgUsicc4waoUE4J4yXspWh8VS6SekD "Lua – Try It Online")
### Human readable code:
```
load(
  "t=".. .....
  "c=#t
   for i=1,c do
     c=math.max(c,#t[i])
   end
   p=io.write
   p'{'
   for i=1,c do 
     for j=1,c do
       _=j==1 and p'{'
       p(t[i]and t[i][j]or 0)
       p(j==c and'}'or',')
     end
     _=i~=c and p','
   end
   p'}'
  ")
()
```
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), 16 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
⁸）⁸∔０；｛ＬＭ｝⁷；：＊⁸ｎ
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXUyMDc4JXVGRjA5JXUyMDc4JXUyMjE0JXVGRjEwJXVGRjFCJXVGRjVCJXVGRjJDJXVGRjJEJXVGRjVEJXUyMDc3JXVGRjFCJXVGRjFBJXVGRjBBJXUyMDc4JXVGRjRF,i=JTVCJTIyYWFhYWElMjIlMkMlMjIlMjIlMkMlMjJjJTIyJTVEJTBBJTIyeCUyMg__,v=8)
Takes an array of strings and a filler string as input.
[Answer]
# [Julia](http://julialang.org/), 82 bytes
```
f(a,b,L=max(length.([a;[a]])...),B=fill(b,L))=[(x->[x;B][1:L]).(a);fill(B,L)][1:L]
```
[Try it online!](https://tio.run/##VY7BqsIwEEX3@YrBVQbG0mp1Yalgd4J/kJdFxFYjMUoboSLv2/umqW9hCGeScy8h16ezJuuHoZGGjnQob6aXrvbncEmkMoUyWmOSJEhV2VjnJHcQSyX7@Vb1RaVVtjlwQxosYl5xPskh1F3ooIRd25rXe@Leh3VO2S9vJYTSxBgJSk/n1WemBGn0H/J1NFOYESwIlgT5v4ilReQyMifgp4Tg3dxbGP8C1sfZCeB1st3DmZccDUbzaK0Pzkv8ypvYoBS/S7MfP0NR@9PwBw "Julia 1.0 – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 83 bytes
```
def f(l,v):x=max(map(len,l+[l]));return[a+[v]*(x-len(a))for a in l+[[]]*(x-len(l))]
```
[Try it online!](https://tio.run/##dY3dCsIwDIXv9xS5TFwE3Q@I4pOUXBRscdB1o8wxn77WVUQFIZCcfOdwxvt0HXwd48VYsOh4puNy7vWCvR7RGc@uVE6ITsFMt@CVLtUsG1y2iaEmskMADZ2H5FPyJo5I4hg6P6FFVQCoPUPLUAs/RZNEvtK7WqeVQhgORMVXLLtWtvtlOVszNH94Dld5fVa/7PEB "Python 3 – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/) with `-m32`, ~~173~~ 163 bytes
Thanks to ceilingcat for -10.
Takes an `NULL`-terminated array of strings and fill character, and returns a `NULL`-terminated array of padded strings with number of rows equal to the string length.
The function scans each string to find the longest length, then creates a destination array of the largest of the row count and maximum string length, plus 1. For each row, a string containing the fill character is allocated and generated, with the original string contents (minus the trailing `NUL`) then copied over the new string. The generated array is then returned to the caller.
```
*b,r,c,l;f(s,f)int*s;{for(r=c=0;s[r];)c=fmax(strlen(s[r++]),c);for(c=r=r>c?r:c,l=b=calloc(c+1,4);r--;*s?*stpcpy(*b,*s++)=f:0,b++)memset(*b=calloc(c+1,1),f,c);s=l;}
```
[Try it online!](https://tio.run/##hZDNbsMgDMfveQqUaRoQMqUfu5TRvkC17bJTmgMloY1E0grItKrKqy8z7Q5TtXZIWOZv@2djlW6UGga6ZpYpZrjGjmlSt546ftQ7i61QIuMutwUnSuhGfmLnralaDFqSFIQpwkOiElbYuVrYGXDEWihpzE5hlYzYlHCbppy6BXV@r/YHDP2oSxIi9Cxja3CaqnGVB/133YgwHfBOGN4Pd3WrTFdW6Nn5st49budRBIOiRtYt/tjVJUHHCCG1lRZR6vJChCdCOCg0L8gRvbwvl6hnl3Ics9O9Fn66EcuyUHw2J/9a4mg8md4KB8I4mEkw08uewQenZ/A36oPteARCWL0XjiPqOdp33uE4DWfVxoQhD6tF5zWExHP81dabupUGSWvlYbZqTwUhvROBAmSC9hZ2q3Gc37sCWNCwAxa/QP20epNlWZV/8TSGYR@yB/Ivto/64UtpIzduSE0zpM1k/A0 "C (gcc) – Try It Online")
[Answer]
# [Japt](https://ethproductions.github.io/japt/), 14 bytes
Takes an array of strings plus a single string as input, outputs an array of strings.
I spent five bytes finding the length of the longest string in the input, I would expect that to be somewhat crunchable.
```
úV ÕúVUñÊo Ê y
ú              // Right-pad every item in the first input to the length of the longest one
 V             // using the second input.
   Õ           // Transpose the rows with the columns,
    ú          // then right-pad every item again as above, except this time
           Ê   // pad to the length
       ñÊo     // of the longest item (sort by length, get the last item)
      U        // in the first input
     V         // using the second input as padding.
             y // Finally, transpose back and implicitly output the result.
```
[Try it out here.](https://ethproductions.github.io/japt/?v=1.4.6&code=+lYg1fpWVfHKbyDKIHk=&input=WyIxMjMiLAogIjEyMzQiLAogIjEyIl0KIjgi)
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~13~~ ~~14~~ ~~12~~ 14 bytes
*Edit: +1 byte to fix bug, then -2 bytes using a different approach, but then +2 bytes after realising we need to provide the fill-value as an argument*
```
₁₁²¹
T⁰ż+³RøLT
```
[Try it online!](https://tio.run/##yygtzv7//1FTIxAd2nRoJ1fIo8YNR/doH9ocdHiHT8j///@jow11jGJ1QKSOMYzWMYmN/W9pCQA "Husk – Try It Online")
**How?**
```
    ₁₁          # apply helper function ₁ twice
                # helper function:
    T0          # transpose, padding with zeros,
      ż+¹       # input list zipped by element-wise concatenation with
         Rø     # a list of empty lists,
           LT   # as long as the longest list in the input list
```
---
Note after reading the other answers: I realised that a port of [Jonathan Allan's approach](https://codegolf.stackexchange.com/a/219050/95126) is 1 byte shorter at [~~11~~ 13 bytes](https://tio.run/##yygtzv7//1FTIxAd2nRoJ1duScijxg1WuecWH9r8////6GhDHaNYHRCpYwyjdUxiY/9bWgIA)...
[Answer]
# [APL](https://www.dyalog.com/), ~~34~~ 30 bytes
```
{M↑M↑¨(,∘S¨⍵),M/¨S←⍺⍴⍨M←⌈/⍴↑⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/2vdR20QQPrRCQ@dRx4zgQyse9W7V1PHVP7Qi@FHbhEe9ux71bnnUu8IXxOnp0Afx2iYC1dT@TwMKUaCf61HfVKCggULao941KBxUfttkQwVDoDZTqJiFQpqChqGCqYKxpoaJgqkmkG0EhKaaUHljiLyRJoL4DwA "APL (Dyalog Classic) – Try It Online")
Might as well put my own APL answer here, even if it is longer than Adám's.
Takes vectors of vectors, and outputs vectors of vectors.
The output with `[]` is a little funky as a result of this, the output is still `[]`, but it would be something akin to an empty vector of vectors.
-4 bytes thanks to looking at a portion of Razetime's answer.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 80 bytes
```
a=>v=>a.map(g=A=>A.map((_,i)=>A.map((_,j)=>x[j]=x[j]||v,x=a[i]=a[i]||[])))&&g(a)
```
[Try it online!](https://tio.run/##fU7LCoMwELz7FTlJFlJpfUAvG/A7QiiLVVGskVrEQ/491aQHD1JYZmeWmWF7Wmiu3t30uYzmWbsGHaFcUFLyoom3WKIsPeUP0cFB9JtYVa9xB2sXsSKpTnuwVmkAiOOWE7jKjLMZ6mQwLW@4ihhTN8EKwTItdpFvIrDtnPopdKSB3wGik3Dwesf13BF6MsHyv65QlIZ1fOYXcl8 "JavaScript (Node.js) – Try It Online")
# [JavaScript (Node.js)](https://nodejs.org), 82 bytes
```
a=>v=>[a,...a].map(A=>A.map((_,i)=>A.map((_,j)=>x[j]=x[j]||v,x=a[i]=a[i]||[])))&&a
```
[Try it online!](https://tio.run/##fU7LCoMwELz7FTlJFrah9QG9RPA7QiiL1aJYI1rEQ/491aQHD1JYZmeWmWE7Wmiupnb8XAbzrF0jHclikYUiFEKQFm8aeSmL0hP@wBYOotvEqjotd7B2wVWSarUHa5UGgDgmV5lhNn0tevPiDVcRY@qGLEeWatxFtonAtnPiJ9eRBn4HiE7Cwesd13NH6EmRZX9doSgJ6/jML@S@ "JavaScript (Node.js) – Try It Online")
Can omit `&&a` claiming return to where `a` was
[Answer]
# [Go](https://go.dev), 144 bytes
```
func f(L[][]int)[][]int{d:=len(L)
for _,e:=range L{if len(e)>d{d=len(e)}}
for j,e:=range L{for i:=len(e);i<d;i++{L[j]=append(L[j],0)}}
return L}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=TVBLasMwFNzrFA-vLKLGaT5QnLqbbr3oPphibMkotWUjOxB46A7ddxMKPVTO0QtUkkUTkJ5mRiNpnr6-m_5yTYey-igbDl0pFZHd0OtpGYluiv5J07elapa9bpJzws9DMray4mP0c5rEw9P1U5xUBSLOD8WhkGqiYcU6zVqu4pwS0Wt4ZzzNtL2IQ45SgNvi9KXGOpuhMd53vPc5QabBsJfP9V4uFpgfjkVWDgNXdewwW7nDmk8nrSA3Idevz-XaiikgqcqRj5Bm4OLNAQniI4Mdg41hBHBrsQdWXPuxM5ajm7agJzhruGKw8uZQLXWK35vPbxhsA_eWta93T1lkwtdULtjctM-JRConvba94nFFyZu2gVt1D0UsFb1Rai8LrV8u8_oH)
]