A computer-implemented method for dynamic data masking of sensitive data, the method comprising: receiving a response output comprising sensitive data, based on a client request, from an application; identifying a main masking specification, based on the response output, for masking of the sensitive data in the response output wherein the main masking specification is identified from one of the predefined masking specifications checking whether any of the predefined masking specification is corrupted and setting a corrupt flag associated with each of the predefined masking specifications to indicate a high or true status on the checking of the predefined masking specifications wherein the corrupt flag is basis for selection of the main masking specification for masking nodes in the DOM tree; checking status of the corrupt flag associated with the main masking specification to check whether the main masking specification is corrupted or tampered; selecting a master masking specification as the main masking specification, when the status of the corrupt flag indicates that the main masking specification is corrupted or tampered; parsing the response output for creating a Document Object Model tree for the response output; checking status of a masking approach indication field of the main masking specification when the status of the corrupt flag is low or false, the masking approach indication field being indicative of whether the main masking specification has information about location identification paths of nodes comprising sensitive data in the DOM tree; and performing masking on the nodes in the DOM tree, wherein the performing of masking is based on the status of the masking approach indication field of the main masking specification wherein the masking of the nodes in the DOM tree comprises: creating an intermediate-node for each of the nodes in the DOM tree to form an intermediate tree representation corresponding to the DOM tree; for each sensitive-intermediate-node, from masking nodes list, fetching masking rule associated with sensitive-intermediate-node; identifying, from the masking rule, a direction of search for searching of the sensitive-intermediate-nodes which are value sensitive; and masking values of the nodes in the DOM tree, corresponding to the sensitive-intermediate-nodes which are value sensitive. receiving a response output comprising sensitive data, based on a client request, from an application; identifying a main masking specification, based on the response output, for masking of the sensitive data in the response output wherein the main masking specification is identified from one of the predefined masking specifications checking whether any of the predefined masking specification is corrupted and setting a corrupt flag associated with each of the predefined masking specifications to indicate a high or true status on the checking of the predefined masking specifications wherein the corrupt flag is basis for selection of the main masking specification for masking nodes in the DOM tree; checking status of the corrupt flag associated with the main masking specification to check whether the main masking specification is corrupted or tampered; selecting a master masking specification as the main masking specification, when the status of the corrupt flag indicates that the main masking specification is corrupted or tampered; parsing the response output for creating a Document Object Model tree for the response output; checking status of a masking approach indication field of the main masking specification when the status of the corrupt flag is low or false, the masking approach indication field being indicative of whether the main masking specification has information about location identification paths of nodes comprising sensitive data in the DOM tree; and performing masking on the nodes in the DOM tree, wherein the performing of masking is based on the status of the masking approach indication field of the main masking specification wherein the masking of the nodes in the DOM tree comprises: creating an intermediate-node for each of the nodes in the DOM tree to form an intermediate tree representation corresponding to the DOM tree; for each sensitive-intermediate-node, from masking nodes list, fetching masking rule associated with sensitive-intermediate-node; identifying, from the masking rule, a direction of search for searching of the sensitive-intermediate-nodes which are value sensitive; and masking values of the nodes in the DOM tree, corresponding to the sensitive-intermediate-nodes which are value sensitive. creating an intermediate-node for each of the nodes in the DOM tree to form an intermediate tree representation corresponding to the DOM tree; for each sensitive-intermediate-node, from masking nodes list, fetching masking rule associated with sensitive-intermediate-node; identifying, from the masking rule, a direction of search for searching of the sensitive-intermediate-nodes which are value sensitive; and masking values of the nodes in the DOM tree, corresponding to the sensitive-intermediate-nodes which are value sensitive.