Is it possible to fit a 347 ford racing engine into a 2004 Mustang?

I'm Planning to purchase a 2004 Mustang and plan to put a new motor in it and was wondering if a 347 would fit?

Yes it would fit.

The 2004 Mustang was available with a 302 ( or 5.0L) engine, the 347 stroker is a modification to the way the engine is built but still using the 302 block.