The field-induced entropy change and the magnetocaloric effect (MCE) of the ferromagnetic shape memory alloys Ni2Mn1-x CuxGa and Ni2Mn1+xIn1-x are studied theoretically on the basis of a phenomenological free energy. The free energy is expanded in powers of the mangetization M and the tetragonal distortion e 3, which are the order parameters for the ferromagnetic and martensitic transitions, respectively. Through the magneto-structural interaction term in the free energy, magnetic fields can affect also e 3 to shift the martensitic first-order transition temperatures. This shift of the transition temperature results in large field-induced changes in the order parameters, which can be responsible for large MCEs. It is found that the resulting MCEs depend on the nature of the magneto-structural interaction. In Ni2Mn1-xCuxGa with the attractive magneto-structural interaction, magnetic fields cause the negative entropy change as in the normal MCE. In Ni2Mn1+xIn1-x with the repulsive interaction, on the other hand, magnetic fields can do the positive entropy change causing the inverse MCE. For both the alloy systems, the x dependences of the refrigerant capacity (RC) are studied to find the compositions optimum for large MCEs. Applicability of the Maxwell relation to the system with the first-order transition is also studied by simulating the field-induced entropy changes on the basis of the Maxwell relation.