User Rating 0.0
Total Usage 0 times
Configure parameters above and click Generate to create your 2D integer array.
Is this tool helpful?

Your feedback helps us improve.

About

Constructing a two-dimensional integer array by hand is tedious and error-prone. A misplaced value in row i, column j can cascade into incorrect matrix multiplications, broken image kernels, or flawed simulation grids. This tool generates arrays of size m × n (up to 50 × 50) using eight deterministic and stochastic fill strategies: uniform random within [min, max], sequential, diagonal, identity, symmetric, spiral, checkerboard, and Pascal row coefficients. Each cell value is a true 32-bit integer. The output is exportable as CSV, JSON array-of-arrays, or plain text. Note: the random generator relies on Math.random, which is a PRNG and not suitable for cryptographic applications.

2d array generator integer matrix grid generator 2d array creator matrix generator number grid

Formulas

The random integer within a closed interval [a, b] is computed as:

value = floor(random() × (b a + 1)) + a

For Pascal's triangle, each cell uses the binomial coefficient:

C(n, k) = n!k! × (n k)!

The identity matrix uses the Kronecker delta:

δij =
{
1 if i = j0 if i j

Where a = minimum value, b = maximum value, n = row index, k = column index, δij = Kronecker delta function.

Reference Data

Fill PatternAlgorithmTypical Use CaseSymmetryValue Range
Randomfloor(random() × (max min + 1)) + minTest data, Monte Carlo inputNone[min, max]
Sequentialstart + (i × cols + j) × stepIndex mapping, lookup tablesNone[start, start + m×n×step]
Diagonali + jWave-front numbering, anti-diagonal indexingAnti-diagonal[0, m+n2]
Identityδ(i,j) × kLinear algebra, basis matricesSymmetric{0, k}
SymmetricA[i][j] = A[j][i]Adjacency matrices, covariance stubsFull symmetric[min, max]
SpiralClockwise layer traversalMatrix traversal problems, interview prepNone[1, m×n]
Checkerboard(i + j) mod 2Tiling, game boards, parity checksAnti-diagonal{val0, val1}
Pascal RowC(i, j) for j iCombinatorics, binomial coefficientsLeft-triangular[0, C(m1, floor((m1)/2))]
Random (Seeded)Mulberry32 PRNG with user seedReproducible test dataNone[min, max]
Band MatrixNon-zero only if |ij| kTridiagonal systems, sparse storageOptional[min, max]
ToeplitzA[i][j] = c[ij]Signal processing, convolutionConstant diagonals[min, max]
HadamardRecursive ±1 matrix (power of 2)Error correction, transformsSymmetric, orthogonal{−1, 1}

Frequently Asked Questions

The maximum is 50 rows × 50 columns (2,500 cells). This cap prevents browser tab freezing caused by DOM node overflow. Each cell is an individual <td> element; beyond ~3,000 nodes, layout recalculation becomes perceptible (>200 ms on mid-range devices). For larger matrices, export as JSON and process programmatically.
No. The tool uses Math.random(), which is a pseudorandom number generator (PRNG) based on xorshift128+ in most engines. It is deterministic given the internal state. For cryptographic applications, use window.crypto.getRandomValues() instead. This tool is designed for test data, not key generation.
The spiral fill uses four boundary pointers: top, bottom, left, right. It traverses left→right along the top row, then top→bottom along the right column, then right→left along the bottom row, then bottom→top along the left column. After each pass, the corresponding boundary contracts inward by 1. The counter increments from 1 to m × n.
The binomial coefficient C(n, k) is defined only for k ≤ n. When column index j exceeds row index i, the value is set to 0. This produces a lower-triangular matrix. The largest value in row i appears at j = floor(i/2) and equals C(i, floor(i/2)).
Yes. Click any cell in the output table to edit its value in-place. Press Enter or click outside to confirm. The internal state array updates immediately, and the heat map canvas re-renders. Edited values persist in localStorage until the next generation.
The export produces a standard JSON array of arrays: [[1,2,3],[4,5,6]]. Each inner array represents one row. Values are native integers, not strings. This format is directly parseable by Python (json.loads), JavaScript (JSON.parse), and most data processing libraries.
The algorithm generates random values only for cells where j ≥ i (upper triangle including diagonal). For cells where j < i, it copies the value from A[j][i]. This guarantees full symmetry. The resulting matrix is suitable as a stub for adjacency matrices or covariance-like structures.