Leibniz entertained various conceptions of infinitesimals, considering them sometimes as ideal things and other times as fictions. But in both cases, he compares infinitesimals favorably to imaginary roots. We agree with the majority of commentators that Leibniz's infinitesimals are fictions rather than ideal things. However, we dispute their opinion that Leibniz's infinitesimals are best understood as logical fictions, eliminable by paraphrase. This so-called syncategorematic conception of infinitesimals is present in Leibniz's texts, but there is an alternative, formalist account of infinitesimals there too. We argue that the formalist account makes better sense of the analogy with imaginary roots and fits better with Leibniz's deepest philosophical convictions. The formalist conception supports the claim of Robinson and others that the philosophical foundations of nonstandard analysis and Leibniz's calculus are cut from the same cloth.