Applications of topology optimization to design compliant cellular mechanisms with and without a contact mechanism are presented in this paper. A two-step procedure is developed. For cellular structures without contact, the inverse homogenization method is employed using 'Solid Isotropic Material with Penalization' approach. The compliant mechanism is optimized to yield prescribed elasticity coefficients. The structure is also required to undergo a large overall strain without exceeding the allowable local strain. Results including a honeycomb similar structure and a negative Poisson's ratio structure are presented. To implement a contact mechanism in the second step, the continuum model of a non-contact structure is converted into a frame model. Such a model is investigated for a contact pair which would reduce the maximum local strain. The scheme demonstrates that stress relief can be obtained.