The honest answer is: it depends on where the map is going. The grids different VTTs and printers expect are not the same size, and the difference is invisible until you import a map and your goblins are suddenly two squares wide.
For Roll20
Roll20 expects 70 pixels per square at default page settings. If you draw or buy a map at 2800 × 1960 pixels, you get a clean 40 × 28 grid. Anything off this multiple will be resampled when you import it.
For Foundry VTT
Foundry's default is 100 pixels per square, but you can change this per scene. For shared maps that travel between systems, 100px is the safer common denominator.
For print
One inch per square at 300 DPI is 300 pixels. A standard tabloid sheet (11 × 17) at the table fits a 17 × 11 grid before bleed. Most home printers will struggle past 200 DPI; aim there if you're not going to a print shop.
The one-inch convention, and why it matters
D&D 5e assumes one square equals five feet, and physical play has settled on one inch per square because that is the footprint a 28mm miniature stands on. Every number above is a different way of expressing the same square. Roll20's 70 pixels, Foundry's 100 and print's 300 are not three grid sizes, they are three resolutions of one grid. Once you think of it that way the conversions stop being arbitrary: a map built at 100px per square prints perfectly at 33% scale, and a 300px map downsamples cleanly to Roll20 at exactly 70/300.
The whole process is four decisions, and only the second one is difficult.
1. Drop the image in
Drag a PNG, JPG or WebP onto the canvas, or click to browse. The file is read by your browser and never sent anywhere, so a 40MB map costs you nothing in upload time. There is no account and no queue.
2. Set the square size
This is the decision that determines whether the export is usable. If you know the map's intended grid, enter it directly. If you do not, the reliable method is to find something of known size in the artwork, usually a door or a bed, and measure against it. A standard door is five feet wide, which is one square. Count how many doors fit across the map, divide the image width by that number, and you have your square size.
If the result is not a whole number, round to the nearest clean factor of the image width rather than accepting the decimal. A square size that divides evenly is the difference between crisp grid lines and a grid that drifts half a pixel per square and looks blurry by the far edge.
3. Nudge the offset
Very few maps start their first square at pixel zero. Most have a border, a frame, or artwork that begins slightly inset. The X and Y offset controls shift the whole grid so that line one lands where the playable area actually starts. Work on one axis at a time and zoom in on a corner while you do it, because an offset that looks right at full view is usually two or three pixels out.
4. Choose line weight and colour
For screen use, a one or two pixel line at low opacity is enough. The grid is a reference, not a feature, and a heavy black grid over good artwork ruins the thing you bought the map for. For print, go slightly heavier than looks right on screen, because ink spread and paper absorbency both soften a thin line. A mid-grey reads better than black on almost every map, and on dark maps a light line at low opacity beats white.
This is the case that causes the most frustration, and it has two different solutions depending on what you need.
If the existing grid is the right scale, do not add a second one. Import the map to your virtual tabletop and align the software's grid to the printed one instead. Roll20 and Foundry both have a grid alignment step for exactly this. Two grids at slightly different offsets is far worse than one grid you have configured around.
If the existing grid is the wrong scale, which happens constantly with maps drawn for other systems or scaled for a different page size, you have a judgement call. Overlaying a correct grid on top of a wrong one produces visual noise, but it is usually still more playable than a map whose squares do not match the movement rules. A low-opacity line in a contrasting colour, clearly different from the artwork's own grid, is the least confusing option at the table.
If the map is gridless, you have the easiest job and the most freedom. Gridless maps are also the ones worth keeping a clean copy of, because a gridless master can be re-gridded for any system later and a gridded export cannot be undone.
DMs running on a virtual tabletop who have bought or found a gridless map and need it to snap correctly in Roll20, Foundry VTT, Fantasy Grounds or Owlbear Rodeo.
DMs printing maps for in-person play, where the grid has to match the miniatures rather than the screen. If the map is larger than one sheet, grid it first and then use the map splitter so the grid stays continuous across the tiles.
DMs running on a TV or tablet laid flat on the table, where the grid needs to match physical minis standing on the glass. Measure the screen's real-world inch, not its pixels, and set the square size so one square measures an inch when displayed at 100%. The tabletop display tool handles pushing the map to a second screen.
Map makers and cartographers checking that a finished map divides cleanly before selling or sharing it. If you draw your own maps, the fantasy cartography guide covers building at a grid-friendly size from the start, which saves this step entirely.