In this paper, a compact hydrostatic-driven electric generator is designed from structure to parameter. The critical point of the structure is to mount a Halbach permanent magnet array on the barrel surface of an axial piston hydrostatic motor.Tradeoff design is carried out for significant parameters based on the utilization of some standard parts. A prototype is fabricated and tested under no-load and loaded conditions. The results show that the prototype has small volume and moment of inertia, reasonable efficiency, as well as good output voltage stiffness and generation quality. The proposed structure and design methodology can also be applied to its reverse pattern, i.e.,electrical-driven hydrostatic pump.Since the hydrostatic parts of the prototype are not speciall designed, there exists some space for further improvement.Future study will focus on performance optimization and controller design when it is supplied to practical electrical load andgoverned by a pulse width modulation rectifier.