A compact and modular pulse forming network (PFN)-Marx generator with output parameters of 5 GW, 500 kV, and 30 Hz repetition is designed and constructed to produce intense electron beams for the purpose of high-power microwave (HPM) generation in the paper. The PFN-Marx is composed by 22 stages of PFN modules, and each module is formed by three mica capacitors (6 nF/50 kV) connected in parallel. Benefiting from the utilization of mica capacitors with high energy density and a mini-trigger source integrated into the magnetic transformer and the magnetic switch, the compactness of the PFN-Marx system is improved significantly. The structure of the PFN module, the gas switch unit, and the connection between PFN modules and switches are well designed for modular realization. Experimental results show that this generator can deliver electrical pulses with the pulse width of 100 ns and amplitude of 500 kV on a 59-ohm water load at a repetition rate of 30 Hz in burst mode. The PFN-Marx generator is fitted into a cuboid stainless steel case with the length of 80 cm. The ratio of storage energy to volume and the ratio of power to weight of the PFN-Marx generator are calculated to be 6.5 J/L and 90 MW/kg, respectively. Furthermore, utilizing the generator to drive the transit time oscillator (TTO) at a voltage level of 450 kV, a 100 MW microwave pulse with the pulse width of 20 ns is generated.