The global production of nitrogen fertilizer amounted to some 117.5 million
metric tons in 2018. China was by far the country with the largest
production, with an output of 28.9 million metric tons of nutrient. It was
followed by the United States and India, with 13.6 and 13.3 million
metric tons produced, respectively.
According to IBISWorld the fertilizer business in the US gets $19.3B in revenue a year, explosives are just $2.3B. I can't imagine that any of the top three countries (China, US and India) have diverted fertilizer production to explosives yet.
I think so far both Russia and Ukraine have been fighting based on stocks that are already manufactured. For instance Russia has about 2,000 S-300 missile launchers and they probably have at least 10x that number of missiles. (Part of the untold story of the cold war is that the Soviets were driven crazy by the threat of the U-2, SR-71, B-52, B-1, B-2, ... and said "no way" and spent more money than they had on air defense.)
Similarly they have been working through large stocks of artillery shells, rockets, etc.
Explosives are surely up in revenue now (double, triple?) and the world is using about every drop of production for both (as with every supply chain).
So, a +/- of $3B is a 16% shock to the fertilizer market. That is plus one year of explosives, but if you are going to war, you might need several years, all at once (pow). We are talking about future prices in the grand scheme.
That is in gross, too, we don't know specific chemical or supply bottlenecks: one kink in ammonia might not mean much except for fertilizer production; if ammonia is produced via hydrocarbon extraction, then fertilizer is not only dependent on energy prices, but competing directly with wartime energy supply.
A 1 ton bomb is pretty good sized, a million of those would be 1% of the mass of a year's fertilizer production.
A B-52 can carry about 30 tons, so that is 33,000 sorties of a B-52. The US has 76 of those, that would be 434 sorties per aircraft. I can picture the B-52 fleet dropping that many bombs in a year.
If anything the situation is probably the reverse, that fertilizer/chemical shortages are causing shortages of explosives for making weapons. Building more Stinger's is currently projected to take a year or two because of difficulties in getting parts. One "part" is the high explosive, whose ingredients come from China, now being affected by lockdowns. If the West was at war with both Russia and China they would likely have to divert some fertilizer to weapons manufacture and agriculture would suffer both from the shortage of imported fertilizer and the extra demand due to weapons manufacture. Even so I'd expect the effect to be small, agriculture must use a lot more chemicals than explosives do.
contain nitrogen. (TATP is not used as a military explosive because it will blow up if you look at it the wrong way.) In a lot of cases that is going to come from nitric acid which in turn is made from ammonia which could otherwise be used to make fertilizer.
As you point out, Ammonium Nitrate is a powerful explosive which is commonly used in mining, road construction and other peaceful purposes. Ammonium Nitrate is also popular among terrorists because it is easy to get and highly effective in the form of a truck bomb.
What's the ratio of "nitrates input" for fertilizer vs explosives? A ton of ammonia is fertilizer all by itself but processed might only be 100kg of TNT (totally ignoring all the other inputs).
I think so far both Russia and Ukraine have been fighting based on stocks that are already manufactured. For instance Russia has about 2,000 S-300 missile launchers and they probably have at least 10x that number of missiles. (Part of the untold story of the cold war is that the Soviets were driven crazy by the threat of the U-2, SR-71, B-52, B-1, B-2, ... and said "no way" and spent more money than they had on air defense.)
Similarly they have been working through large stocks of artillery shells, rockets, etc.