Ideally, a window box should be the same length as the window frame it sits under. While a difference of an inch or two won’t make a big difference, the closer the sizing the cleaner the final look will be.
If matching your window boxes to the exact window size isn’t possible, try to opt for a planter that is longer rather than shorter. A shorter window box will cut off the window frame and make it look smaller. Meanwhile, a longer window box will frame the window and draw attention to it.